diff --git a/src/Squidex/Startup.cs b/src/Squidex/Startup.cs index df05ccd37..3671edcf3 100644 --- a/src/Squidex/Startup.cs +++ b/src/Squidex/Startup.cs @@ -98,7 +98,7 @@ namespace Squidex if (!Environment.IsDevelopment()) { - app.UseMiddleware(); + //app.UseMiddleware(); } MapAndUseIdentity(app); diff --git a/src/Squidex/app-config/auto-loader.js b/src/Squidex/app-config/auto-loader.js index 0e00c23b2..58cf6ce0c 100644 --- a/src/Squidex/app-config/auto-loader.js +++ b/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; + } - Object.keys(query).forEach(function (baggageFile) { - var baggageVar = query[baggageFile]; + var componentOffset = source.indexOf('@Component'); - if (typeof baggageVar === 'string' || baggageVar === true) { - baggageFile = applyPlaceholders(baggageFile, srcDirname, srcFilename); + if (componentOffset < 0) { + componentOffset = source.indexOf('@Ng2.Component'); + } - try { - var stats = fs.statSync(path.resolve(srcDirpath, baggageFile)); + if (componentOffset < 0) { + return source; + } - if (stats.isFile()) { - if (baggageVar.length) { - inject += 'const ' + baggageVar + ' = '; - } + Object.keys(query).forEach(function (baggageFile) { + var baggageVar = query[baggageFile]; + + 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()) { + let replacement = null; - if (baggageVar === 'styles') { - inject += '[require(\'./' + baggageFile + '\')];\n'; + if (baggageVar === 'styles') { + 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; - return inject + source; - } + source = source.replace(baggageVar, function (match, offset, full) { + if (isReplaced || offset <= componentOffset) { + return baggageVar; + } else { + isReplaced = true; + + return baggageVar + ': ' + replacement; + } + }); + } + } catch (e) { } + } + }); return source; }; diff --git a/src/Squidex/app-config/webpack.common.js b/src/Squidex/app-config/webpack.common.js index a6bc9feb9..61960064b 100644 --- a/src/Squidex/app-config/webpack.common.js +++ b/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'), @@ -82,15 +74,31 @@ module.exports = { } ] }, - - sassLoader: { - includePaths: [helpers.root('app', 'theme')] - }, 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: '/' + } + }), + /** - * 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. * diff --git a/src/Squidex/app-config/webpack.config.js b/src/Squidex/app-config/webpack.config.js new file mode 100644 index 000000000..cf948977e --- /dev/null +++ b/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' + }) + ] +}; \ No newline at end of file diff --git a/src/Squidex/app-config/webpack.coverage.js b/src/Squidex/app-config/webpack.coverage.js index 5e4ca1056..8def31ccb 100644 --- a/src/Squidex/app-config/webpack.coverage.js +++ b/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'), diff --git a/src/Squidex/app-config/webpack.dev.js b/src/Squidex/app-config/webpack.dev.js index 2086dc189..d23624bad 100644 --- a/src/Squidex/app-config/webpack.dev.js +++ b/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' } diff --git a/src/Squidex/app-config/webpack.prod.js b/src/Squidex/app-config/webpack.prod.js index 316a01748..a65577feb 100644 --- a/src/Squidex/app-config/webpack.prod.js +++ b/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 () { diff --git a/src/Squidex/app-config/webpack.test.js b/src/Squidex/app-config/webpack.test.js index b4985ad9b..feddf423f 100644 --- a/src/Squidex/app-config/webpack.test.js +++ b/src/Squidex/app-config/webpack.test.js @@ -1,81 +1,6 @@ -var webpack = require('webpack'), - helpers = require('./helpers'); + 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' - }) - ] -} \ No newline at end of file +module.exports = webpackMerge(commonConfig, { }); \ No newline at end of file diff --git a/src/Squidex/app/app.module.ts b/src/Squidex/app/app.module.ts index d05adbf9a..bb43c31cc 100644 --- a/src/Squidex/app/app.module.ts +++ b/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: [ diff --git a/src/Squidex/app/framework/angular/action.ts b/src/Squidex/app/framework/angular/action.ts index 83054b9c4..d32580017 100644 --- a/src/Squidex/app/framework/angular/action.ts +++ b/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 = () => { }); } }; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/Squidex/app/framework/utils/date-time.spec.ts b/src/Squidex/app/framework/utils/date-time.spec.ts index 565517c92..eecf533be 100644 --- a/src/Squidex/app/framework/utils/date-time.spec.ts +++ b/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'; diff --git a/src/Squidex/appsettings.Production.json b/src/Squidex/appsettings.Production.json index e8e8e1338..40ee5bbcb 100644 --- a/src/Squidex/appsettings.Production.json +++ b/src/Squidex/appsettings.Production.json @@ -1,5 +1,5 @@ { "identity": { - "baseUrl": "https://squidex.io" + "baseUrl": "http://squidex.io" } } \ No newline at end of file diff --git a/src/Squidex/package.json b/src/Squidex/package.json index 92ce8779e..0df2bb5b2 100644 --- a/src/Squidex/package.json +++ b/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" } }