diff --git a/etc/appConfig.js b/etc/appConfig.js index 2074f76..e39cc8c 100644 --- a/etc/appConfig.js +++ b/etc/appConfig.js @@ -17,9 +17,13 @@ var appConfig = { chunks: { name: ['polyfills', 'vendor'].reverse() }, - srcSASS: path.resolve(sourceRoot, 'scss'), - srcI18N: path.resolve(sourceRoot, 'app', 'i18n'), - srcIMG: path.resolve(sourceRoot, 'img'), + copy: [{ + from: path.resolve(sourceRoot, 'img'), + to: 'img' + }, { + from: path.resolve(sourceRoot, 'i18n'), + to: 'i18n' + }], indexFiles: [{ chunks: ['main', 'polyfills', 'vendor'], template: path.resolve(sourceRoot, 'index.html'), diff --git a/etc/webpack.common.js b/etc/webpack.common.js index 1f60541..b827639 100755 --- a/etc/webpack.common.js +++ b/etc/webpack.common.js @@ -10,7 +10,8 @@ const webpack = require('webpack'); /* * Webpack Plugins */ -const {TsConfigPathsPlugin, CheckerPlugin} = require('awesome-typescript-loader'); +const CheckerPlugin = require('awesome-typescript-loader').TsConfigPathsPlugin; +const TsConfigPathsPlugin = require('awesome-typescript-loader').CheckerPlugin; const CopyWebpackPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const WebpackNotifierPlugin = require('webpack-notifier'); @@ -48,13 +49,6 @@ var config = { warnings: false, publicPath: false }, - /* - * Static metadata for index.html - * - * See: (custom attribute) - */ - metadata: METADATA, - /* * The entry point for the bundle @@ -76,22 +70,13 @@ var config = { * * See: http://webpack.github.io/docs/configuration.html#resolve-extensions */ - extensions: ['', '.ts', '.js', '.json'], + extensions: ['.ts', '.js', '.json'], // Make sure root is src - root: appConfig.src, - - // remove other default values - modulesDirectories: ['node_modules'] - - }, - - htmlLoader: { - minimize: true, - removeAttributeQuotes: false, - caseSensitive: true, - customAttrSurround: [[/#/, /(?:)/], [/\*/, /(?:)/], [/\[?\(?/, /(?:)/]], - customAttrAssign: [/\)?\]?=/] + modules: [ + appConfig.src, + 'node_modules' + ] }, /* @@ -104,12 +89,20 @@ var config = { // resolve https://github.com/holisticon/angular-common/issues/10 exprContextCritical: false, + noParse: [ + /angular2|zone.js/ + ], + /* - * An array of applied pre and post loaders. + * 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-preloaders-module-postloaders + * See: http://webpack.github.io/docs/configuration.html#module-loaders */ - preLoaders: [ + rules: [ + // PRE-LOADERS { test: /\.ts$/, loader: 'string-replace-loader', @@ -118,7 +111,8 @@ var config = { replace: '$1.import($3).then(mod => (mod.__esModule && mod.default) ? mod.default : mod)', flags: 'g' }, - include: [helpers.root('src')] + include: [helpers.root('src')], + enforce: 'pre' }, /* @@ -132,7 +126,8 @@ var config = { exclude: [ /node_modules/, /\.(html|css|sass)$/ - ] + ], + enforce: 'pre' }, /* @@ -150,25 +145,10 @@ var config = { helpers.root('node_modules/@angular'), helpers.root('node_modules/@ngrx'), helpers.root('node_modules/@angular2-material') - ] - } - - ], - noParse: [ - path.join(__dirname, 'node_modules', 'zone.js', 'dist'), - path.join(__dirname, 'node_modules', 'angular2', 'bundles') - ], - - /* - * 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: [ - + ], + enforce: 'pre' + }, + // LOADERS /* * Typescript loader support for .ts and Angular 2 async routes via .async.ts * @@ -179,20 +159,12 @@ var config = { test: /\.ts$/, loaders: ['awesome-typescript-loader', 'angular2-template-loader'] }, - /* - * Json loader support for *.json files. - * - * See: https://github.com/webpack/json-loader - */ - { - test: /\.json$/, - loader: 'json-loader' - }, { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' }, // https://github.com/jtangelder/sass-loader#usage + // TODO appConfig.srcSASS { test: /\.scss$/, loaders: ["style", "css", "sass"] @@ -221,9 +193,6 @@ var config = { ] }, - sassLoader: { - includePaths: [appConfig.srcSASS] - }, /* * Add additional plugins to the compiler. @@ -265,13 +234,7 @@ var config = { * * See: https://www.npmjs.com/package/copy-webpack-plugin */ - new CopyWebpackPlugin([{ - from: appConfig.srcIMG, - to: 'img' - }, { - from: appConfig.srcI18N, - to: 'i18n' - }]), + new CopyWebpackPlugin(appConfig.copy), /** * Plugin: DefinePlugin * Description: Define free variables. @@ -300,7 +263,7 @@ var config = { * See: https://webpack.github.io/docs/configuration.html#node */ node: { - global: 'window', + global: true, crypto: 'empty', module: false, clearImmediate: false, diff --git a/etc/webpack.prod.js b/etc/webpack.prod.js index 148e1b5..3daada2 100755 --- a/etc/webpack.prod.js +++ b/etc/webpack.prod.js @@ -11,7 +11,7 @@ const commonConfig = require('./webpack.common.js'); // the settings that are co /** * Webpack Plugins */ -const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin; +const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin; const ProvidePlugin = webpack.ProvidePlugin; const DefinePlugin = webpack.DefinePlugin; const NormalModuleReplacementPlugin = webpack.NormalModuleReplacementPlugin; @@ -35,13 +35,6 @@ const METADATA = webpackMerge(commonConfig.metadata, { module.exports = webpackMerge(commonConfig, { - /** - * Switch loaders to debug mode. - * - * See: http://webpack.github.io/docs/configuration.html#debug - */ - debug: false, - /** * Options affecting the output of the compilation. * @@ -100,12 +93,13 @@ module.exports = webpackMerge(commonConfig, { new webpack.optimize.CommonsChunkPlugin(appConfig.chunks), /* - * Plugin: ForkCheckerPlugin + * Plugin: CheckerPlugin * Description: Do type checking in a separate process, so webpack don't need to wait. * - * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse + * See: https://github.com/s-panferov/awesome-typescript-loader#configuration */ - new ForkCheckerPlugin(), + new CheckerPlugin(), + /** * Plugin: WebpackMd5Hash @@ -219,51 +213,6 @@ module.exports = webpackMerge(commonConfig, { // threshold: 2 * 1024 // }) - ], - - /** - * Static analysis linter for TypeScript advanced options configuration - * Description: An extensible linter for the TypeScript language. - * - * See: https://github.com/wbuchwalter/tslint-loader - */ - tslint: { - emitErrors: true, - failOnHint: true, - resourcePath: appConfig.srcApp - }, - - /** - * Html loader advanced options - * - * See: https://github.com/webpack/html-loader#advanced-options - */ - // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor - htmlLoader: { - minimize: true, - removeAttributeQuotes: false, - caseSensitive: true, - customAttrSurround: [ - [/#/, /(?:)/], - [/\*/, /(?:)/], - [/\[?\(?/, /(?:)/] - ], - customAttrAssign: [/\)?\]?=/] - }, - - /* - * Include polyfills or mocks for various node stuff - * Description: Node configuration - * - * See: https://webpack.github.io/docs/configuration.html#node - */ - node: { - global: 'window', - crypto: 'empty', - process: false, - module: false, - clearImmediate: false, - setImmediate: false - } + ] }); diff --git a/etc/webpack.test.js b/etc/webpack.test.js index 386f4a1..591b194 100755 --- a/etc/webpack.test.js +++ b/etc/webpack.test.js @@ -43,13 +43,8 @@ module.exports = webpackMerge(commonConfig, { * See: http://webpack.github.io/docs/configuration.html#module */ module: { - - /** - * An array of applied pre and post loaders. - * - * See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders - */ - postLoaders: [ + rules: [ + // POST-LOADERS /** * Instruments JS files with Istanbul for subsequent code coverage reporting. @@ -67,7 +62,8 @@ module.exports = webpackMerge(commonConfig, { exclude: [ /\.(e2e|spec)\.ts$/, /node_modules/ - ] + ], + enforce: 'post' } ] diff --git a/package.json b/package.json index 2f9d57e..9160a66 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "babel-plugin-transform-es2015-constants": "6.1.4", "babel-polyfill": "6.16.0", "babel-preset-es2015": "6.16.0", - "codelyzer": "0.0.28", + "codelyzer": "1.0.0-beta.4", "concurrently": "3.1.0", "copy-webpack-plugin": "4.0.1", "core-js": "2.4.1", @@ -79,9 +79,9 @@ "to-string-loader": "1.1.5", "ts-helpers": "1.1.1", "ts-node": "1.4.1", - "tslint": "3.15.1", + "tslint": "4.3.1", "tslint-eslint-rules": "2.1.0", - "tslint-loader": "3.3.0", + "tslint-loader": "3.2.1", "typedoc": "0.4.5", "typescript": "2.0.3", "typings": "1.4.0", diff --git a/test/appConfigTest.js b/test/appConfigTest.js index 11cf87c..c778aba 100644 --- a/test/appConfigTest.js +++ b/test/appConfigTest.js @@ -1,6 +1,7 @@ var appConfig = { srcPath: 'app', genPath: 'src-gen', + copy: [], testPath: 'specs', junit: { name: 'Holisticon-TestApp', dir: '../target/test-reports'