diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-11-04 12:50:01 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-11-04 12:50:01 +0100 |
commit | 4d19d2f10b691650abe030d0dbb52dc7c8a62441 (patch) | |
tree | 2ec321237cb4c43948848418bc114559e0cc1ffe /client/config/webpack.common.js | |
parent | d05eb4ed10db5737173946cc15b1193ce498529b (diff) | |
download | PeerTube-4d19d2f10b691650abe030d0dbb52dc7c8a62441.tar.gz PeerTube-4d19d2f10b691650abe030d0dbb52dc7c8a62441.tar.zst PeerTube-4d19d2f10b691650abe030d0dbb52dc7c8a62441.zip |
Update to webpack beta 25
Diffstat (limited to 'client/config/webpack.common.js')
-rw-r--r-- | client/config/webpack.common.js | 88 |
1 files changed, 36 insertions, 52 deletions
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') | |||
10 | const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin | 10 | const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin |
11 | const AssetsPlugin = require('assets-webpack-plugin') | 11 | const AssetsPlugin = require('assets-webpack-plugin') |
12 | const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin') | 12 | const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin') |
13 | const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') | ||
14 | const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') | ||
13 | const WebpackNotifierPlugin = require('webpack-notifier') | 15 | const WebpackNotifierPlugin = require('webpack-notifier') |
14 | 16 | ||
15 | /* | 17 | /* |
@@ -30,12 +32,6 @@ module.exports = function (options) { | |||
30 | var isProd = options.env === 'production' | 32 | var isProd = options.env === 'production' |
31 | 33 | ||
32 | return { | 34 | return { |
33 | /* | ||
34 | * Static metadata for index.html | ||
35 | * | ||
36 | * See: (custom attribute) | ||
37 | */ | ||
38 | metadata: METADATA, | ||
39 | 35 | ||
40 | /* | 36 | /* |
41 | * Cache generated modules and chunks to improve performance for multiple incremental builds. | 37 | * Cache generated modules and chunks to improve performance for multiple incremental builds. |
@@ -69,17 +65,9 @@ module.exports = function (options) { | |||
69 | * | 65 | * |
70 | * See: http://webpack.github.io/docs/configuration.html#resolve-extensions | 66 | * See: http://webpack.github.io/docs/configuration.html#resolve-extensions |
71 | */ | 67 | */ |
72 | extensions: [ '', '.ts', '.js', '.scss' ], | 68 | extensions: [ '.ts', '.js', '.json', '.scss' ], |
73 | |||
74 | // Make sure root is src | ||
75 | root: helpers.root('src'), | ||
76 | 69 | ||
77 | // remove other default values | 70 | modules: [helpers.root('src'), 'node_modules'] |
78 | modulesDirectories: [ 'node_modules' ] | ||
79 | }, | ||
80 | |||
81 | output: { | ||
82 | publicPath: '/client/' | ||
83 | }, | 71 | }, |
84 | 72 | ||
85 | /* | 73 | /* |
@@ -88,33 +76,8 @@ module.exports = function (options) { | |||
88 | * See: http://webpack.github.io/docs/configuration.html#module | 76 | * See: http://webpack.github.io/docs/configuration.html#module |
89 | */ | 77 | */ |
90 | module: { | 78 | module: { |
91 | /* | ||
92 | * An array of applied pre and post loaders. | ||
93 | * | ||
94 | * See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders | ||
95 | */ | ||
96 | preLoaders: [ | ||
97 | { | ||
98 | test: /\.ts$/, | ||
99 | loader: 'string-replace-loader', | ||
100 | query: { | ||
101 | search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)', | ||
102 | replace: '$1.import($3).then(mod => (mod.__esModule && mod.default) ? mod.default : mod)', | ||
103 | flags: 'g' | ||
104 | }, | ||
105 | include: [helpers.root('src')] | ||
106 | } | ||
107 | ], | ||
108 | 79 | ||
109 | /* | 80 | rules: [ |
110 | * An array of automatically applied loaders. | ||
111 | * | ||
112 | * IMPORTANT: The loaders here are resolved relative to the resource which they are applied to. | ||
113 | * This means they are not resolved relative to the configuration file. | ||
114 | * | ||
115 | * See: http://webpack.github.io/docs/configuration.html#module-loaders | ||
116 | */ | ||
117 | loaders: [ | ||
118 | 81 | ||
119 | /* | 82 | /* |
120 | * Typescript loader support for .ts and Angular 2 async routes via .async.ts | 83 | * Typescript loader support for .ts and Angular 2 async routes via .async.ts |
@@ -163,10 +126,6 @@ module.exports = function (options) { | |||
163 | 126 | ||
164 | }, | 127 | }, |
165 | 128 | ||
166 | sassLoader: { | ||
167 | precision: 10 | ||
168 | }, | ||
169 | |||
170 | /* | 129 | /* |
171 | * Add additional plugins to the compiler. | 130 | * Add additional plugins to the compiler. |
172 | * | 131 | * |
@@ -205,7 +164,7 @@ module.exports = function (options) { | |||
205 | * | 164 | * |
206 | * See: https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin | 165 | * See: https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin |
207 | * See: https://github.com/angular/angular/issues/11580 | 166 | * See: https://github.com/angular/angular/issues/11580 |
208 | */ | 167 | */ |
209 | new ContextReplacementPlugin( | 168 | new ContextReplacementPlugin( |
210 | // The (\\|\/) piece accounts for path separators in *nix and Windows | 169 | // The (\\|\/) piece accounts for path separators in *nix and Windows |
211 | /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, | 170 | /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, |
@@ -241,10 +200,36 @@ module.exports = function (options) { | |||
241 | */ | 200 | */ |
242 | new HtmlWebpackPlugin({ | 201 | new HtmlWebpackPlugin({ |
243 | template: 'src/index.html', | 202 | template: 'src/index.html', |
244 | chunksSortMode: 'dependency' | 203 | title: METADATA.title, |
204 | chunksSortMode: 'dependency', | ||
205 | metadata: METADATA | ||
206 | }), | ||
207 | |||
208 | /* | ||
209 | * Plugin: ScriptExtHtmlWebpackPlugin | ||
210 | * Description: Enhances html-webpack-plugin functionality | ||
211 | * with different deployment options for your scripts including: | ||
212 | * | ||
213 | * See: https://github.com/numical/script-ext-html-webpack-plugin | ||
214 | */ | ||
215 | new ScriptExtHtmlWebpackPlugin({ | ||
216 | defaultAttribute: 'defer' | ||
245 | }), | 217 | }), |
246 | 218 | ||
247 | new WebpackNotifierPlugin({ alwaysNotify: true }) | 219 | new WebpackNotifierPlugin({ alwaysNotify: true }), |
220 | |||
221 | /** | ||
222 | * Plugin LoaderOptionsPlugin (experimental) | ||
223 | * | ||
224 | * See: https://gist.github.com/sokra/27b24881210b56bbaff7 | ||
225 | */ | ||
226 | new LoaderOptionsPlugin({ | ||
227 | options: { | ||
228 | sassLoader: { | ||
229 | precision: 10 | ||
230 | } | ||
231 | } | ||
232 | }) | ||
248 | ], | 233 | ], |
249 | 234 | ||
250 | /* | 235 | /* |
@@ -254,10 +239,9 @@ module.exports = function (options) { | |||
254 | * See: https://webpack.github.io/docs/configuration.html#node | 239 | * See: https://webpack.github.io/docs/configuration.html#node |
255 | */ | 240 | */ |
256 | node: { | 241 | node: { |
257 | global: 'window', | 242 | global: 'true', |
258 | crypto: 'empty', | 243 | crypto: 'empty', |
259 | fs: 'empty', | 244 | process: true, |
260 | events: true, | ||
261 | module: false, | 245 | module: false, |
262 | clearImmediate: false, | 246 | clearImmediate: false, |
263 | setImmediate: false | 247 | setImmediate: false |