From 8635a2c70cc24a4c52558162ac058de95750271f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 11 Jun 2017 12:28:22 +0200 Subject: Update client modules --- client/config/webpack.common.js | 67 +++++++++++++++++++++++++++-------------- client/config/webpack.dev.js | 3 +- client/config/webpack.prod.js | 45 +++------------------------ 3 files changed, 50 insertions(+), 65 deletions(-) (limited to 'client/config') diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js index 6067d94e7..266e630f6 100644 --- a/client/config/webpack.common.js +++ b/client/config/webpack.common.js @@ -85,23 +85,37 @@ module.exports = function (options) { rules: [ /* - * Typescript loader support for .ts and Angular 2 async routes via .async.ts + * Typescript loader support for .ts and Angular async routes via .async.ts * * See: https://github.com/s-panferov/awesome-typescript-loader */ { test: /\.ts$/, use: [ - '@angularclass/hmr-loader?pretty=' + !isProd + '&prod=' + isProd, - 'awesome-typescript-loader?{configFileName: "tsconfig.webpack.json"}', - 'angular2-template-loader', + { + loader: '@angularclass/hmr-loader', + options: { + pretty: !isProd, + prod: isProd + } + }, { loader: 'ng-router-loader', options: { - loader: 'async-system', + loader: 'async-import', genDir: 'compiled', aot: AOT } + }, + { + loader: 'awesome-typescript-loader', + options: { + configFileName: 'tsconfig.webpack.json', + useCache: !isProd + } + }, + { + loader: 'angular2-template-loader' } ], exclude: [/\.(spec|e2e)\.ts$/] @@ -114,7 +128,7 @@ module.exports = function (options) { */ { test: /\.json$/, - loader: 'json-loader' + use: 'json-loader' }, { @@ -149,7 +163,7 @@ module.exports = function (options) { */ { test: /\.html$/, - loader: 'raw-loader', + use: 'raw-loader', exclude: [ helpers.root('src/index.html'), helpers.root('src/standalone/videos/embed.html') @@ -213,11 +227,15 @@ module.exports = function (options) { * See: https://github.com/angular/angular/issues/11580 */ new ContextReplacementPlugin( - // The (\\|\/) piece accounts for path separators in *nix and Windows - /angular(\\|\/)core(\\|\/)src(\\|\/)linker/, + /** + * The (\\|\/) piece accounts for path separators in *nix and Windows + */ + /angular(\\|\/)core(\\|\/)@angular/, helpers.root('src'), // location of your src { - // your Angular Async Route paths relative to this root directory + /** + * Your Angular Async Route paths relative to this root directory + */ } ), @@ -245,6 +263,20 @@ module.exports = function (options) { } ]), + /* + * Plugin: ScriptExtHtmlWebpackPlugin + * Description: Enhances html-webpack-plugin functionality + * with different deployment options for your scripts including: + * + * See: https://github.com/numical/script-ext-html-webpack-plugin + */ + new ScriptExtHtmlWebpackPlugin({ + sync: [ /polyfill|vendor/, 'webtorrent.min.js' ], + defaultAttribute: 'async', + preload: [/polyfill|vendor|main/], + prefetch: [/chunk/] + }), + /* * Plugin: HtmlWebpackPlugin * Description: Simplifies creation of HTML files to serve your webpack bundles. @@ -257,19 +289,8 @@ module.exports = function (options) { template: 'src/index.html', title: METADATA.title, chunksSortMode: 'dependency', - metadata: METADATA - }), - - /* - * Plugin: ScriptExtHtmlWebpackPlugin - * Description: Enhances html-webpack-plugin functionality - * with different deployment options for your scripts including: - * - * See: https://github.com/numical/script-ext-html-webpack-plugin - */ - new ScriptExtHtmlWebpackPlugin({ - sync: [ 'webtorrent.min.js' ], - defaultAttribute: 'defer' + metadata: METADATA, + inject: 'body' }), new WebpackNotifierPlugin({ alwaysNotify: true }), diff --git a/client/config/webpack.dev.js b/client/config/webpack.dev.js index 5e0f36d7f..03d6d2fba 100644 --- a/client/config/webpack.dev.js +++ b/client/config/webpack.dev.js @@ -233,8 +233,7 @@ module.exports = function (env) { host: METADATA.host, historyApiFallback: true, watchOptions: { - aggregateTimeout: 300, - poll: 1000 + ignored: /node_modules/ }, outputPath: helpers.root('dist') }, diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js index 6d65fcb37..9bb7306af 100644 --- a/client/config/webpack.prod.js +++ b/client/config/webpack.prod.js @@ -14,7 +14,7 @@ const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin') const OptimizeJsPlugin = require('optimize-js-plugin') const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin') -const WebpackMd5Hash = require('webpack-md5-hash') +const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin') /** * Webpack Constants @@ -67,7 +67,7 @@ module.exports = function (env) { * * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename */ - sourceMapFilename: '[name].[chunkhash].bundle.map', + sourceMapFilename: '[file].map', /** * The filename of non-entry chunks as relative path @@ -75,7 +75,7 @@ module.exports = function (env) { * * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename */ - chunkFilename: '[id].[chunkhash].chunk.js', + chunkFilename: '[name].[chunkhash].chunk.js', publicPath: '/client/' }, @@ -91,14 +91,6 @@ module.exports = function (env) { */ plugins: [ - /** - * Plugin: WebpackMd5Hash - * Description: Plugin to replace a standard webpack chunkhash with md5. - * - * See: https://www.npmjs.com/package/webpack-md5-hash - */ - new WebpackMd5Hash(), - /** * Webpack plugin to optimize a JavaScript file for faster initial load * by wrapping eagerly-invoked functions. @@ -194,35 +186,7 @@ module.exports = function (env) { helpers.root('config/empty.js') ), - // AoT - // new NormalModuleReplacementPlugin( - // /@angular(\\|\/)upgrade/, - // helpers.root('config/empty.js') - // ), - // new NormalModuleReplacementPlugin( - // /@angular(\\|\/)compiler/, - // helpers.root('config/empty.js') - // ), - // new NormalModuleReplacementPlugin( - // /@angular(\\|\/)platform-browser-dynamic/, - // helpers.root('config/empty.js') - // ), - // new NormalModuleReplacementPlugin( - // /dom(\\|\/)debug(\\|\/)ng_probe/, - // helpers.root('config/empty.js') - // ), - // new NormalModuleReplacementPlugin( - // /dom(\\|\/)debug(\\|\/)by/, - // helpers.root('config/empty.js') - // ), - // new NormalModuleReplacementPlugin( - // /src(\\|\/)debug(\\|\/)debug_node/, - // helpers.root('config/empty.js') - // ), - // new NormalModuleReplacementPlugin( - // /src(\\|\/)debug(\\|\/)debug_renderer/, - // helpers.root('config/empty.js') - // ), + new HashedModuleIdsPlugin(), /** * Plugin: IgnorePlugin @@ -252,6 +216,7 @@ module.exports = function (env) { * See: https://gist.github.com/sokra/27b24881210b56bbaff7 */ new LoaderOptionsPlugin({ + minimize: true, debug: false, options: { -- cgit v1.2.3