Webpack upgraded from 4 to 5 + dependancies updated

This commit is contained in:
Simounet 2020-11-11 09:48:04 +01:00
parent c8e7722fd1
commit 9937d3a060
No known key found for this signature in database
GPG key ID: 77D3B7DC794EB770
7 changed files with 1634 additions and 2204 deletions

View file

@ -1,3 +1,13 @@
{ {
"extends": "stylelint-config-standard" "extends": "stylelint-config-standard",
"plugins": [
"stylelint-scss"
],
rules: {
'at-rule-no-unknown': null,
'no-duplicate-selectors': null,
'font-family-no-missing-generic-family-keyword': null,
'no-descending-specificity': null,
'scss/at-rule-no-unknown': true,
},
} }

View file

@ -4,8 +4,7 @@ const StyleLintPlugin = require('stylelint-webpack-plugin');
const rootDir = path.resolve(__dirname, '../../../'); const rootDir = path.resolve(__dirname, '../../../');
module.exports = function () { module.exports = {
return {
entry: { entry: {
material: path.join(rootDir, './app/Resources/static/themes/material/index.js'), material: path.join(rootDir, './app/Resources/static/themes/material/index.js'),
baggy: path.join(rootDir, './app/Resources/static/themes/baggy/index.js'), baggy: path.join(rootDir, './app/Resources/static/themes/baggy/index.js'),
@ -37,4 +36,3 @@ module.exports = function () {
}, },
}, },
}; };
};

View file

@ -2,8 +2,7 @@ const { merge } = require('webpack-merge');
const webpack = require('webpack'); const webpack = require('webpack');
const commonConfig = require('./common.js'); const commonConfig = require('./common.js');
module.exports = function () { module.exports = merge(commonConfig, {
return merge(commonConfig(), {
devtool: 'eval-source-map', devtool: 'eval-source-map',
output: { output: {
filename: '[name].dev.js', filename: '[name].dev.js',
@ -32,7 +31,7 @@ module.exports = function () {
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['@babel/preset-env'] presets: ['@babel/preset-env'],
}, },
}, },
}, },
@ -49,7 +48,9 @@ module.exports = function () {
{ {
loader: 'postcss-loader', loader: 'postcss-loader',
options: { options: {
plugins: [require('autoprefixer')({})], postcssOptions: {
plugins: ['autoprefixer'],
},
}, },
}, },
'sass-loader', 'sass-loader',
@ -62,4 +63,3 @@ module.exports = function () {
], ],
}, },
}); });
};

View file

@ -6,19 +6,17 @@ const TerserPlugin = require('terser-webpack-plugin');
const commonConfig = require('./common.js'); const commonConfig = require('./common.js');
module.exports = function () { module.exports = merge(commonConfig, {
return merge(commonConfig(), {
output: { output: {
filename: '[name].js', filename: '[name].js',
}, },
mode: 'production', mode: 'production',
devtool: 'source-map', devtool: 'source-map',
optimization: { optimization: {
minimize: true,
minimizer: [ minimizer: [
new TerserPlugin({ new TerserPlugin({
cache: true,
parallel: true, parallel: true,
sourceMap: true,
terserOptions: { terserOptions: {
output: { output: {
comments: false, comments: false,
@ -26,18 +24,15 @@ module.exports = function () {
}, },
extractComments: false, extractComments: false,
}), }),
] ],
}, },
plugins: [ plugins: [
new MiniCssExtractPlugin(),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env': { 'process.env': {
'NODE_ENV': JSON.stringify('production'), NODE_ENV: JSON.stringify('production'),
}, },
}), }),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new ManifestPlugin({ new ManifestPlugin({
fileName: 'manifest.json', fileName: 'manifest.json',
}), }),
@ -56,19 +51,14 @@ module.exports = function () {
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['@babel/preset-env'] presets: ['@babel/preset-env'],
}, },
}, },
}, },
{ {
test: /\.(sa|sc|c)ss$/, test: /\.(sa|sc|c)ss$/,
use: [ use: [
{ MiniCssExtractPlugin.loader,
loader: MiniCssExtractPlugin.loader,
options: {
hmr: process.env.NODE_ENV === 'development',
},
},
{ {
loader: 'css-loader', loader: 'css-loader',
options: { options: {
@ -78,7 +68,9 @@ module.exports = function () {
{ {
loader: 'postcss-loader', loader: 'postcss-loader',
options: { options: {
plugins: [require('autoprefixer')({})], postcssOptions: {
plugins: ['autoprefixer'],
},
}, },
}, },
'sass-loader', 'sass-loader',
@ -117,4 +109,3 @@ module.exports = function () {
], ],
}, },
}); });
};

View file

@ -38,29 +38,32 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.3", "@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1", "@babel/preset-env": "^7.12.1",
"autoprefixer": "^9.8.6", "autoprefixer": "^10.0.2",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"babel-loader": "^8.2.1", "babel-loader": "^8.2.1",
"css-loader": "^4.3.0", "css-loader": "^5.0.1",
"eslint": "^7.13.0", "eslint": "^7.13.0",
"eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-base": "^14.2.1",
"eslint-loader": "^4.0.2", "eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"lato-font": "^3.0.0", "lato-font": "^3.0.0",
"mini-css-extract-plugin": "^1.2.1", "mini-css-extract-plugin": "^1.3.0",
"node-sass": "^5.0.0", "node-sass": "^5.0.0",
"postcss-loader": "^3.0.0", "postcss": "^8.1.6",
"postcss-loader": "^4.0.4",
"sass": "^1.29.0",
"sass-loader": "^10.0.5", "sass-loader": "^10.0.5",
"style-loader": "^2.0.0", "style-loader": "^2.0.0",
"stylelint": "^7.9.0", "stylelint": "^13.7.2",
"stylelint-config-standard": "^16.0.0", "stylelint-config-standard": "^20.0.0",
"stylelint-webpack-plugin": "^1.0.0", "stylelint-scss": "^3.18.0",
"stylelint-webpack-plugin": "^2.1.1",
"url-loader": "^4.1.1", "url-loader": "^4.1.1",
"webpack": "^4.44.2", "webpack": "^5.4.0",
"webpack-cli": "^3.3.12", "webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0", "webpack-dev-server": "^3.11.0",
"webpack-manifest-plugin": "^2.2.0", "webpack-manifest-plugin": "^3.0.0-rc.0",
"webpack-merge": "^5.3.0" "webpack-merge": "^5.3.0"
}, },
"dependencies": { "dependencies": {

View file

@ -1,8 +1,8 @@
const path = require('path'); const path = require('path');
function buildConfig(env) { function buildConfig(options) {
env = env || 'prod'; const env = options.prod ? 'prod' : 'dev';
return require(path.resolve(__dirname, 'app/config/webpack/' + env + '.js'))({ env: env }) return require(path.resolve(__dirname, `app/config/webpack/${env}.js`));
} }
module.exports = buildConfig; module.exports = buildConfig;

3434
yarn.lock

File diff suppressed because it is too large Load diff