Browse Source

Temp

pull/1/head
Sebastian 9 years ago
parent
commit
154f8c5de8
  1. 2
      src/Squidex/Startup.cs
  2. 48
      src/Squidex/app-config/auto-loader.js
  3. 47
      src/Squidex/app-config/webpack.common.js
  4. 100
      src/Squidex/app-config/webpack.config.js
  5. 2
      src/Squidex/app-config/webpack.coverage.js
  6. 17
      src/Squidex/app-config/webpack.dev.js
  7. 45
      src/Squidex/app-config/webpack.prod.js
  8. 83
      src/Squidex/app-config/webpack.test.js
  9. 2
      src/Squidex/app/app.module.ts
  10. 18
      src/Squidex/app/framework/angular/action.ts
  11. 2
      src/Squidex/app/framework/utils/date-time.spec.ts
  12. 2
      src/Squidex/appsettings.Production.json
  13. 25
      src/Squidex/package.json

2
src/Squidex/Startup.cs

@ -98,7 +98,7 @@ namespace Squidex
if (!Environment.IsDevelopment())
{
app.UseMiddleware<SingleUrlsMiddleware>();
//app.UseMiddleware<SingleUrlsMiddleware>();
}
MapAndUseIdentity(app);

48
src/Squidex/app-config/auto-loader.js

@ -29,37 +29,61 @@ function loadBaggage(source, sourcemap) {
this.cacheable();
if (Object.keys(query).length) {
var inject = '\n/* injects from baggage-loader */\n';
if (!Object.keys(query).length) {
return source;
}
var componentOffset = source.indexOf('@Component');
if (componentOffset < 0) {
componentOffset = source.indexOf('@Ng2.Component');
}
if (componentOffset < 0) {
return source;
}
Object.keys(query).forEach(function (baggageFile) {
var baggageVar = query[baggageFile];
if (typeof baggageVar === 'string' || baggageVar === true) {
if ((typeof baggageVar === 'string' || baggageVar === true) && baggageFile !== 'noRequire') {
baggageFile = applyPlaceholders(baggageFile, srcDirname, srcFilename);
try {
var stats = fs.statSync(path.resolve(srcDirpath, baggageFile));
if (stats.isFile()) {
if (baggageVar.length) {
inject += 'const ' + baggageVar + ' = ';
}
let replacement = null;
if (baggageVar === 'styles') {
inject += '[require(\'./' + baggageFile + '\')];\n';
if (query.noRequire) {
replacement = '[\'' + baggageFile + '\']';
} else {
inject += 'require(\'./' + baggageFile + '\');\n';
replacement = '[require(\'./' + baggageFile + '\')]';
}
} else {
if (query.noRequire) {
replacement = '\'' + baggageFile + '\'';
} else {
replacement = 'require(\'./' + baggageFile + '\')';
}
} catch (e) { }
}
});
inject += '\n';
var isReplaced = false;
source = source.replace(baggageVar, function (match, offset, full) {
if (isReplaced || offset <= componentOffset) {
return baggageVar;
} else {
isReplaced = true;
return inject + source;
return baggageVar + ': ' + replacement;
}
});
}
} catch (e) { }
}
});
return source;
};

47
src/Squidex/app-config/webpack.common.js

@ -31,16 +31,13 @@ module.exports = {
*
* See: http://webpack.github.io/docs/configuration.html#resolve-extensions
*/
extensions: ['', '.js', '.ts', '.css', '.scss'],
root: [
extensions: ['.js', '.ts', '.css', '.scss'],
modules: [
helpers.root('app'),
helpers.root('app-libs')
helpers.root('app', 'theme'),
helpers.root('app-libs'),
helpers.root('node_modules')
],
moduleDirectories: [
'*',
'app/*',
'app/theme/*'
]
},
/*
@ -49,11 +46,6 @@ module.exports = {
* See: http://webpack.github.io/docs/configuration.html#module
*/
module: {
preLoaders: [{
test: /\.ts/,
loader: helpers.root('app-config', 'auto-loader') + '?[file].html=template&[file].scss=styles',
}],
/**
* An array of automatically applied loaders.
*
@ -65,7 +57,7 @@ module.exports = {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
loaders: ['awesome-typescript', helpers.root('app-config', 'auto-loader') + '?[file].html=template&[file].scss=styles', 'tslint']
}, {
test: /\.html$/,
loader: 'html'
@ -74,7 +66,7 @@ module.exports = {
loader: 'file?name=assets/[name].[hash].[ext]'
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap')
loader: ExtractTextPlugin.extract({ fallbackLoader: 'style', loader: 'css?sourceMap' })
}, {
test: /\.scss$/,
exclude: helpers.root('app', 'theme'),
@ -83,14 +75,30 @@ module.exports = {
]
},
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
tslint: {
/**
* Run tslint in production build and fail if there is one warning.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
emitErrors: false,
/**
* Share the configuration file with the IDE
*/
configuration: require('./../tslint.json')
},
sassLoader: {
includePaths: [helpers.root('app', 'theme')]
},
context: '/'
}
}),
plugins: [
/**
* Plugin: CommonsChunkPlugin
* Description: Shares common code between the pages.
* Shares common code between the pages.
* It identifies common modules and put them into a commons chunk.
*
* See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
@ -100,8 +108,7 @@ module.exports = {
}),
/**
* Plugin: HtmlWebpackPlugin
* Description: Simplifies creation of HTML files to serve your webpack bundles.
* Simplifies creation of HTML files to serve your webpack bundles.
* This is especially useful for webpack bundles that include a hash in the filename
* which changes every compilation.
*

100
src/Squidex/app-config/webpack.config.js

@ -0,0 +1,100 @@
// ReSharper disable InconsistentNaming
// ReSharper disable PossiblyUnassignedProperty
var webpack = require('webpack'),
path = require('path'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
helpers = require('./helpers');
module.exports = {
/**
* Options affecting the resolving of modules.
*
* See: http://webpack.github.io/docs/configuration.html#resolve
*/
resolve: {
/**
* An array of extensions that should be used to resolve modules.
*
* See: http://webpack.github.io/docs/configuration.html#resolve-extensions
*/
extensions: ['.js', '.ts', '.css', '.scss'],
modules: [
helpers.root('app'),
helpers.root('app', 'theme'),
helpers.root('app-libs'),
helpers.root('node_modules')
],
},
/*
* Options affecting the normal modules.
*
* See: http://webpack.github.io/docs/configuration.html#module
*/
module: {
/**
* An array of automatically applied loaders.
*
* IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
* This means they are not resolved relative to the configuration file.
*
* See: http://webpack.github.io/docs/configuration.html#module-loaders
*/
loaders: [
{
test: /\.ts$/,
loaders: ['awesome-typescript', helpers.root('app-config', 'auto-loader') + '?[file].html=template&[file].scss=styles', 'tslint']
}, {
test: /\.html$/,
loader: 'html'
}, {
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?.*$|$)/,
loader: 'file?name=assets/[name].[hash].[ext]'
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract({ fallbackLoader: 'style', loader: 'css?sourceMap' })
}, {
test: /\.scss$/,
exclude: helpers.root('app', 'theme'),
loaders: ['raw', 'sass']
}
]
},
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
tslint: {
/**
* Run tslint in production build and fail if there is one warning.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
emitErrors: false,
/**
* Share the configuration file with the IDE
*/
configuration: require('./../tslint.json')
},
sassLoader: {
includePaths: [helpers.root('app', 'theme')]
},
context: '/'
}
}),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
/**
* Shim additional libraries
*
* See: https://webpack.github.io/docs/shimming-modules.html
*/
new webpack.ProvidePlugin({
// Mouse trap handles shortcut management
'Mousetrap': 'mousetrap/mousetrap'
})
]
};

2
src/Squidex/app-config/webpack.coverage.js

@ -6,7 +6,7 @@ var webpackMerge = require('webpack-merge'),
module.exports = webpackMerge(testConfig, {
module: {
postLoaders: [
loaders: [
{
test: /\.(js|ts)$/,
include: helpers.root('app'),

17
src/Squidex/app-config/webpack.dev.js

@ -48,23 +48,6 @@ module.exports = webpackMerge(commonConfig, {
new ExtractTextPlugin('[name].css')
],
sassLoader: {
includePaths: [helpers.root('app', 'theme')]
},
tslint: {
/**
* Run tslint in production build, but do not fail if there is a warning.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
failOnHint: false,
/**
* Share the configuration file with the IDE
*/
configuration: require('./../tslint.json')
},
devServer: {
historyApiFallback: true, stats: 'minimal'
}

45
src/Squidex/app-config/webpack.prod.js

@ -6,6 +6,8 @@ ExtractTextPlugin = require('extract-text-webpack-plugin'),
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
commonConfig.plugins[0].options.options.tslint.emitErrors = true;
module.exports = webpackMerge(commonConfig, {
devtool: 'source-map',
@ -42,11 +44,6 @@ module.exports = webpackMerge(commonConfig, {
* See: http://webpack.github.io/docs/configuration.html#module
*/
module: {
preLoaders: [{
test: /\.ts$/,
loader: 'tslint'
}],
/**
* An array of automatically applied loaders.
*
@ -59,38 +56,26 @@ module.exports = webpackMerge(commonConfig, {
{
test: /\.scss$/,
include: helpers.root('app', 'theme'),
loader: ExtractTextPlugin.extract('style', 'css!sass?sourceMap')
loader: ExtractTextPlugin.extract({ fallbackLoader: 'style', loader: 'css!sass?sourceMap' })
}
]
},
tslint: {
/**
* Run tslint in production build and fail if there is one warning.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
failOnHint: true,
/**
* Share the configuration file with the IDE
*/
configuration: require('./../tslint.json')
},
/**
* Html loader advanced options
*
* See: https://github.com/webpack/html-loader#advanced-options
*/
htmlLoader: {
minimize: false
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: { screw_ie8: true, keep_fnames: true } }),
new webpack.DefinePlugin({ 'process.env': { 'ENV': JSON.stringify(ENV) } }),
new webpack.optimize.UglifyJsPlugin({
mangle: {
screw_ie8: true, keep_fnames: true
}
}),
/*
* Puts each bundle into a file and appends the hash of the file to the path.
*
* See: https://github.com/webpack/extract-text-webpack-plugin
*/
new ExtractTextPlugin('[name].[hash].css'),
function () {

83
src/Squidex/app-config/webpack.test.js

@ -1,81 +1,6 @@
var webpack = require('webpack'),
 var webpack = require('webpack'),
webpackMerge = require('webpack-merge'),
commonConfig = require('./webpack.config.js'),
helpers = require('./helpers');
module.exports = {
/**
* Source map for Karma from the help of karma-sourcemap-loader & karma-webpack
*
* Do not change, leave as is or it wont work.
* See: https://github.com/webpack/karma-webpack#source-maps
*/
devtool: 'inline-source-map',
resolve: {
/**
* An array of extensions that should be used to resolve modules.
*
* See: http://webpack.github.io/docs/configuration.html#resolve-extensions
*/
extensions: ['', '.ts', '.js'],
root: [
helpers.root('app'),
helpers.root('app-libs')
]
},
/*
* Options affecting the normal modules.
*
* See: http://webpack.github.io/docs/configuration.html#module
*/
module: {
preLoaders: [{
test: /\.ts/,
loader: helpers.root('app-config', 'auto-loader') + '?[file].html=template&[file].scss=styles',
}],
/**
* An array of automatically applied loaders.
*
* IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
* This means they are not resolved relative to the configuration file.
*
* See: http://webpack.github.io/docs/configuration.html#module-loaders
*/
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
}, {
test: /\.html$/,
loader: 'html'
}, {
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?.*$|$)/,
loader: 'null'
}, {
test: /\.css$/,
loader: 'null'
}, {
test: /\.scss$/,
exclude: helpers.root('app', 'theme'),
loaders: ['raw', 'sass']
}
]
},
sassLoader: {
includePaths: [helpers.root('app', 'theme')]
},
plugins: [
/**
* Shim additional libraries
*
* See: https://webpack.github.io/docs/shimming-modules.html
*/
new webpack.ProvidePlugin({
// Mouse trap handles shortcut management
'Mousetrap': 'mousetrap/mousetrap'
})
]
}
module.exports = webpackMerge(commonConfig, { });

2
src/Squidex/app/app.module.ts

@ -36,7 +36,7 @@ import {
import { routing } from './app.routes';
const baseUrl = window.location.protocol + '//' + window.location.host + '/';
const baseUrl = window.location.protocol + '//' + window.location.host + '/';;;
@Ng2.NgModule({
imports: [

18
src/Squidex/app/framework/angular/action.ts

@ -7,14 +7,16 @@
const EMPTY_FUNC = () => { };
export const Action = () => {
return (target: any, key: string) => {
/* tslint:disable:only-arrow-functions */
export function Action() {
return function (target: any, key: string) {
let observable: any;
let instance: any;
let subscriptions: any;
let subscription: any;
const subscribe = () => {
function subscribe() {
const store = instance.store;
if (store && observable && observable.subscribe && typeof observable.subscribe === 'function') {
@ -24,7 +26,7 @@ export const Action = () => {
}
};
const unsubscribe = () => {
function unsubscribe() {
if (subscription) {
subscription.unsubscribe();
@ -34,16 +36,16 @@ export const Action = () => {
if (delete target[key]) {
Object.defineProperty(target, key, {
get: () => {
get: function () {
return observable;
},
set: (v) => {
set: function (v) {
instance = this;
if (!instance.___subscriptions) {
instance.___subscriptions = [];
const destroy = instance.ngOnDestroy ? instance.ngOnDestroy.bind(instance) : EMPTY_FUNC;
let destroy = instance.ngOnDestroy ? instance.ngOnDestroy.bind(instance) : EMPTY_FUNC;
instance.ngOnDestroy = () => {
for (let s of subscriptions) {
@ -66,4 +68,4 @@ export const Action = () => {
});
}
};
};
}

2
src/Squidex/app/framework/utils/date-time.spec.ts

@ -78,7 +78,7 @@ describe('DateTime', () => {
});
it('should print to formatted string', () => {
const value = DateTime.parseISO_UTC('2013-10-16T12:13:14T');
const value = DateTime.parseISO_UTC('2013-10-16T12:13:14');
const actual = value.toStringFormat('hh:mm');
const expected = '12:13';

2
src/Squidex/appsettings.Production.json

@ -1,5 +1,5 @@
{
"identity": {
"baseUrl": "https://squidex.io"
"baseUrl": "http://squidex.io"
}
}

25
src/Squidex/package.json

@ -14,18 +14,20 @@
"build:clean": "rimraf wwwroot/build"
},
"dependencies": {
"@angular/common": "2.1.1",
"@angular/compiler": "2.1.1",
"@angular/core": "2.1.1",
"@angular/forms": "2.1.1",
"@angular/http": "2.1.1",
"@angular/platform-browser": "2.1.1",
"@angular/platform-browser-dynamic": "2.1.1",
"@angular/router": "3.1.1",
"@angular/common": "^2",
"@angular/compiler": "^2",
"@angular/core": "^2",
"@angular/forms": "^2",
"@angular/http": "^2",
"@angular/platform-browser": "^2",
"@angular/platform-browser-dynamic": "^2",
"@angular/router": "^3",
"babel-polyfill": "^6.16.0",
"bootstrap": "^4.0.0-alpha.2",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"immutable": "^3.8.1",
"moment": "^2.14.0",
"mousetrap": "^1.6.0",
"oidc-client": "^1.2.1-beta.3",
"reflect-metadata": "^0.1.3",
@ -42,7 +44,7 @@
"cpx": "^1.5.0",
"css-loader": "^0.25.0",
"exports-loader": "^0.6.3",
"extract-text-webpack-plugin": "^1.0.1",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^0.9.0",
"font-awesome-sass-loader": "^1.0.1",
"html-loader": "^0.4.3",
@ -59,7 +61,6 @@
"karma-phantomjs-launcher": "^1.0.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"moment": "^2.14.0",
"node-sass": "^3.8.0",
"null-loader": "^0.1.1",
"phantomjs-prebuilt": "^2.1.7",
@ -73,8 +74,8 @@
"typemoq": "^0.3.2",
"typescript": "^2.0.6",
"underscore": "^1.8.3",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.14.1",
"webpack": "2.1.0-beta.25",
"webpack-dev-server": "2.1.0-beta.10",
"webpack-merge": "^0.15.0"
}
}

Loading…
Cancel
Save