feat(webpack): reduce lodash size

pull/2670/head
Chaim Lev-Ari 2018-11-12 21:56:51 +02:00
parent 1b57b657bd
commit 558036ee53
3 changed files with 15 additions and 5 deletions

View File

@ -24,7 +24,7 @@
"dev": "yarn grunt run-dev",
"clean-all": "yarn grunt clean:all",
"dev:client": "webpack",
"build:client": "webpack --config ./webpack/webpack.production.js",
"build:client": "webpack -p --config ./webpack/webpack.production.js",
"build-offline": "cd ./api/cmd/portainer && CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags '-s' && mv -b portainer ../../../dist/portainer-linux-amd64"
},
"engines": {
@ -101,6 +101,7 @@
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"load-grunt-tasks": "^3.5.2",
"lodash-webpack-plugin": "^0.11.5",
"mini-css-extract-plugin": "^0.4.4",
"ngtemplate-loader": "^2.0.1",
"style-loader": "^0.23.1",

View File

@ -1,11 +1,12 @@
const path = require('path');
const { ProvidePlugin, ContextReplacementPlugin } = require('webpack');
const { ProvidePlugin, IgnorePlugin } = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const npmPackage = require('../package.json');
const projectRoot = path.resolve(__dirname, '..');
@ -92,7 +93,7 @@ module.exports = {
new ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'window.jQuery': 'jquery'
}),
new MiniCssExtractPlugin({
filename: '[name].css',
@ -100,8 +101,9 @@ module.exports = {
sourceMap: true
}),
new CleanWebpackPlugin(['dist/public']),
new ContextReplacementPlugin(/moment[\/\\]locale$/, /en/)
new IgnorePlugin(/^\.\/locale$/, /moment$/),
// new BundleAnalyzerPlugin()
new LodashModuleReplacementPlugin()
],
optimization: {
splitChunks: {

View File

@ -5396,6 +5396,13 @@ locate-path@^3.0.0:
p-locate "^3.0.0"
path-exists "^3.0.0"
lodash-webpack-plugin@^0.11.5:
version "0.11.5"
resolved "https://registry.yarnpkg.com/lodash-webpack-plugin/-/lodash-webpack-plugin-0.11.5.tgz#c4bd064b4f561c3f823fa5982bdeb12c475390b9"
integrity sha512-QWfEIYxpixOdbd6KBe5g6MDWcyTgP3trDXwKHFqTlXrWiLcs/67fGQ0IWeRyhWlTITQIgMpJAYd2oeIztuV5VA==
dependencies:
lodash "^4.17.4"
lodash._basecopy@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
@ -5591,7 +5598,7 @@ lodash@^4.17.10:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
integrity sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==
lodash@^4.17.3, lodash@^4.17.5, lodash@~4.17.4:
lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@~4.17.4:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==