aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/config
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-09 14:28:44 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-09 14:28:44 +0200
commita685e25ca05f08ad1b3f7fbaccc8744727bd8d27 (patch)
treee50fbc2f260a0017113c4668c3c0f3d2fd76ab87 /client/config
parent2ed6a0aedc2d2f6b1ac2fd9a1ac137772831f713 (diff)
downloadPeerTube-a685e25ca05f08ad1b3f7fbaccc8744727bd8d27.tar.gz
PeerTube-a685e25ca05f08ad1b3f7fbaccc8744727bd8d27.tar.zst
PeerTube-a685e25ca05f08ad1b3f7fbaccc8744727bd8d27.zip
Try to optimize frontend
Diffstat (limited to 'client/config')
-rw-r--r--client/config/webpack.common.js37
-rw-r--r--client/config/webpack.prod.js16
2 files changed, 27 insertions, 26 deletions
diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js
index 000699aa5..83bcbc240 100644
--- a/client/config/webpack.common.js
+++ b/client/config/webpack.common.js
@@ -11,6 +11,7 @@ const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
11const HtmlWebpackPlugin = require('html-webpack-plugin') 11const HtmlWebpackPlugin = require('html-webpack-plugin')
12const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') 12const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
13const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') 13const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
14const InlineManifestWebpackPlugin = require('inline-manifest-webpack-plugin')
14const ngcWebpack = require('ngc-webpack') 15const ngcWebpack = require('ngc-webpack')
15 16
16const WebpackNotifierPlugin = require('webpack-notifier') 17const WebpackNotifierPlugin = require('webpack-notifier')
@@ -216,7 +217,9 @@ module.exports = function (options) {
216 new CommonsChunkPlugin({ 217 new CommonsChunkPlugin({
217 name: 'vendor', 218 name: 'vendor',
218 chunks: ['main'], 219 chunks: ['main'],
219 minChunks: module => /node_modules\//.test(module.resource) 220 minChunks: module => {
221 return /node_modules\//.test(module.resource)
222 }
220 }), 223 }),
221 224
222 // Specify the correct order the scripts will be injected in 225 // Specify the correct order the scripts will be injected in
@@ -245,20 +248,6 @@ module.exports = function (options) {
245 ), 248 ),
246 249
247 /* 250 /*
248 * Plugin: ScriptExtHtmlWebpackPlugin
249 * Description: Enhances html-webpack-plugin functionality
250 * with different deployment options for your scripts including:
251 *
252 * See: https://github.com/numical/script-ext-html-webpack-plugin
253 */
254 new ScriptExtHtmlWebpackPlugin({
255 sync: [ /polyfill|vendor/ ],
256 defaultAttribute: 'async',
257 preload: [/polyfill|vendor|main/],
258 prefetch: [/chunk/]
259 }),
260
261 /*
262 * Plugin: HtmlWebpackPlugin 251 * Plugin: HtmlWebpackPlugin
263 * Description: Simplifies creation of HTML files to serve your webpack bundles. 252 * Description: Simplifies creation of HTML files to serve your webpack bundles.
264 * This is especially useful for webpack bundles that include a hash in the filename 253 * This is especially useful for webpack bundles that include a hash in the filename
@@ -277,6 +266,20 @@ module.exports = function (options) {
277 inject: 'body' 266 inject: 'body'
278 }), 267 }),
279 268
269 /*
270 * Plugin: ScriptExtHtmlWebpackPlugin
271 * Description: Enhances html-webpack-plugin functionality
272 * with different deployment options for your scripts including:
273 *
274 * See: https://github.com/numical/script-ext-html-webpack-plugin
275 */
276 new ScriptExtHtmlWebpackPlugin({
277 sync: [ /polyfill|vendor/ ],
278 defaultAttribute: 'async',
279 preload: [/polyfill|vendor|main/],
280 prefetch: [/chunk/]
281 }),
282
280 new WebpackNotifierPlugin({ alwaysNotify: true }), 283 new WebpackNotifierPlugin({ alwaysNotify: true }),
281 284
282 /** 285 /**
@@ -296,7 +299,9 @@ module.exports = function (options) {
296 new ngcWebpack.NgcWebpackPlugin({ 299 new ngcWebpack.NgcWebpackPlugin({
297 disabled: !AOT, 300 disabled: !AOT,
298 tsConfig: helpers.root('tsconfig.webpack.json') 301 tsConfig: helpers.root('tsconfig.webpack.json')
299 }) 302 }),
303
304 new InlineManifestWebpackPlugin(),
300 ], 305 ],
301 306
302 /* 307 /*
diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js
index 777c816e8..ecd7914c7 100644
--- a/client/config/webpack.prod.js
+++ b/client/config/webpack.prod.js
@@ -17,6 +17,8 @@ const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplaceme
17const OptimizeJsPlugin = require('optimize-js-plugin') 17const OptimizeJsPlugin = require('optimize-js-plugin')
18const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin') 18const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin')
19const UglifyJsPlugin = require('uglifyjs-webpack-plugin') 19const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
20const ExtractTextPlugin = require('extract-text-webpack-plugin')
21
20/** 22/**
21 * Webpack Constants 23 * Webpack Constants
22 */ 24 */
@@ -120,15 +122,10 @@ module.exports = function (env) {
120 sourceMap: false 122 sourceMap: false
121 }), 123 }),
122 124
123 /** 125 new ExtractTextPlugin({
124 * Plugin: DedupePlugin 126 filename: '[name].[contenthash].css',
125 * Description: Prevents the inclusion of duplicate code into your bundle 127 allChunks: true
126 * and instead applies a copy of the function at runtime. 128 }),
127 *
128 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
129 * See: https://github.com/webpack/docs/wiki/optimization#deduplication
130 */
131 // new DedupePlugin(),
132 129
133 /** 130 /**
134 * Plugin: DefinePlugin 131 * Plugin: DefinePlugin
@@ -158,7 +155,6 @@ module.exports = function (env) {
158 * 155 *
159 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin 156 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
160 */ 157 */
161 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines
162 new UglifyJsPlugin({ 158 new UglifyJsPlugin({
163 parallel: true, 159 parallel: true,
164 uglifyOptions: { 160 uglifyOptions: {