X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fconfig%2Fwebpack.common.js;h=5ef5621e64c18da962ba8e4f7152ea8b0416791a;hb=4d19d2f10b691650abe030d0dbb52dc7c8a62441;hp=882013a9e1b6f7c481e2d35d23ab3529fd23e89e;hpb=ad22074a780b4bdbe3cd9e903b3fa5ef83eaef14;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js index 882013a9e..5ef5621e6 100644 --- a/client/config/webpack.common.js +++ b/client/config/webpack.common.js @@ -10,6 +10,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin') const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin const AssetsPlugin = require('assets-webpack-plugin') const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin') +const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') +const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') const WebpackNotifierPlugin = require('webpack-notifier') /* @@ -30,12 +32,6 @@ module.exports = function (options) { var isProd = options.env === 'production' return { - /* - * Static metadata for index.html - * - * See: (custom attribute) - */ - metadata: METADATA, /* * Cache generated modules and chunks to improve performance for multiple incremental builds. @@ -69,17 +65,9 @@ module.exports = function (options) { * * See: http://webpack.github.io/docs/configuration.html#resolve-extensions */ - extensions: [ '', '.ts', '.js', '.scss' ], - - // Make sure root is src - root: helpers.root('src'), + extensions: [ '.ts', '.js', '.json', '.scss' ], - // remove other default values - modulesDirectories: [ 'node_modules' ] - }, - - output: { - publicPath: '/client/' + modules: [helpers.root('src'), 'node_modules'] }, /* @@ -88,33 +76,8 @@ module.exports = function (options) { * 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 - */ - preLoaders: [ - { - test: /\.ts$/, - loader: 'string-replace-loader', - query: { - search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)', - replace: '$1.import($3).then(mod => (mod.__esModule && mod.default) ? mod.default : mod)', - flags: 'g' - }, - include: [helpers.root('src')] - } - ], - /* - * 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: [ + rules: [ /* * Typescript loader support for .ts and Angular 2 async routes via .async.ts @@ -163,10 +126,6 @@ module.exports = function (options) { }, - sassLoader: { - precision: 10 - }, - /* * Add additional plugins to the compiler. * @@ -205,7 +164,7 @@ module.exports = function (options) { * * See: https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin * See: https://github.com/angular/angular/issues/11580 - */ + */ new ContextReplacementPlugin( // The (\\|\/) piece accounts for path separators in *nix and Windows /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, @@ -241,10 +200,36 @@ module.exports = function (options) { */ new HtmlWebpackPlugin({ template: 'src/index.html', - chunksSortMode: 'dependency' + 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({ + defaultAttribute: 'defer' }), - new WebpackNotifierPlugin({ alwaysNotify: true }) + new WebpackNotifierPlugin({ alwaysNotify: true }), + + /** + * Plugin LoaderOptionsPlugin (experimental) + * + * See: https://gist.github.com/sokra/27b24881210b56bbaff7 + */ + new LoaderOptionsPlugin({ + options: { + sassLoader: { + precision: 10 + } + } + }) ], /* @@ -254,10 +239,9 @@ module.exports = function (options) { * See: https://webpack.github.io/docs/configuration.html#node */ node: { - global: 'window', + global: 'true', crypto: 'empty', - fs: 'empty', - events: true, + process: true, module: false, clearImmediate: false, setImmediate: false