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,37 +4,35 @@ 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'), public: path.join(rootDir, './app/Resources/static/themes/_global/share.js'),
public: path.join(rootDir, './app/Resources/static/themes/_global/share.js'), },
output: {
filename: '[name].js',
path: path.resolve(rootDir, 'web/wallassets'),
publicPath: '',
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.$': 'jquery',
'window.jQuery': 'jquery',
}),
new StyleLintPlugin({
configFile: '.stylelintrc',
failOnError: false,
quiet: false,
context: 'app/Resources/static/themes',
files: '**/*.scss',
}),
],
resolve: {
alias: {
jquery: path.join(rootDir, 'node_modules/jquery/dist/jquery.js'),
}, },
output: { },
filename: '[name].js',
path: path.resolve(rootDir, 'web/wallassets'),
publicPath: '',
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.$': 'jquery',
'window.jQuery': 'jquery',
}),
new StyleLintPlugin({
configFile: '.stylelintrc',
failOnError: false,
quiet: false,
context: 'app/Resources/static/themes',
files: '**/*.scss',
}),
],
resolve: {
alias: {
jquery: path.join(rootDir, 'node_modules/jquery/dist/jquery.js'),
},
},
};
}; };

View file

@ -2,64 +2,64 @@ 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', },
}, mode: 'development',
mode: 'development', devServer: {
devServer: { hot: true,
hot: true, // enable HMR on the server
// enable HMR on the server contentBase: './web',
contentBase: './web', // match the output path
// match the output path },
}, plugins: [
plugins: [ new webpack.HotModuleReplacementPlugin(),
new webpack.HotModuleReplacementPlugin(), ],
], module: {
module: { rules: [
rules: [ {
{ enforce: 'pre',
enforce: 'pre', test: /\.js$/,
test: /\.js$/, loader: 'eslint-loader',
loader: 'eslint-loader', exclude: /node_modules/,
exclude: /node_modules/, },
}, {
{ test: /\.js$/,
test: /\.js$/, exclude: /(node_modules)/,
exclude: /(node_modules)/, use: {
use: { loader: 'babel-loader',
loader: 'babel-loader', options: {
options: { presets: ['@babel/preset-env'],
presets: ['@babel/preset-env']
},
}, },
}, },
{ },
test: /\.(s)?css$/, {
use: [ test: /\.(s)?css$/,
'style-loader', use: [
{ 'style-loader',
loader: 'css-loader', {
options: { loader: 'css-loader',
importLoaders: 1, options: {
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: ['autoprefixer'],
}, },
}, },
{ },
loader: 'postcss-loader', 'sass-loader',
options: { ],
plugins: [require('autoprefixer')({})], },
}, {
}, test: /\.(jpg|png|gif|svg|ico|eot|ttf|woff|woff2)$/,
'sass-loader', use: 'url-loader',
], },
}, ],
{ },
test: /\.(jpg|png|gif|svg|ico|eot|ttf|woff|woff2)$/, });
use: 'url-loader',
},
],
},
});
};

View file

@ -6,115 +6,106 @@ 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, terserOptions: {
sourceMap: true, output: {
terserOptions: { comments: false,
output: {
comments: false,
},
}, },
extractComments: false,
}),
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
}, },
}), extractComments: false,
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new ManifestPlugin({
fileName: 'manifest.json',
}), }),
], ],
module: { },
rules: [ plugins: [
{ new MiniCssExtractPlugin(),
enforce: 'pre', new webpack.DefinePlugin({
test: /\.js$/, 'process.env': {
loader: 'eslint-loader', NODE_ENV: JSON.stringify('production'),
exclude: /node_modules/, },
}, }),
{ new ManifestPlugin({
test: /\.js$/, fileName: 'manifest.json',
exclude: /(node_modules)/, }),
use: { ],
loader: 'babel-loader', module: {
options: { rules: [
presets: ['@babel/preset-env'] {
}, enforce: 'pre',
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
}, },
}, },
{ },
test: /\.(sa|sc|c)ss$/, {
use: [ test: /\.(sa|sc|c)ss$/,
{ use: [
loader: MiniCssExtractPlugin.loader, MiniCssExtractPlugin.loader,
options: { {
hmr: process.env.NODE_ENV === 'development', loader: 'css-loader',
options: {
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: ['autoprefixer'],
}, },
}, },
{ },
loader: 'css-loader', 'sass-loader',
options: { ],
importLoaders: 1, },
}, {
}, test: /\.(jpg|png|gif|svg|ico)$/,
{ include: /node_modules/,
loader: 'postcss-loader', use: {
options: { loader: 'file-loader',
plugins: [require('autoprefixer')({})], options: {
}, name: 'img/[name].[ext]',
},
'sass-loader',
],
},
{
test: /\.(jpg|png|gif|svg|ico)$/,
include: /node_modules/,
use: {
loader: 'file-loader',
options: {
name: 'img/[name].[ext]',
},
}, },
}, },
{ },
test: /\.(jpg|png|gif|svg|ico)$/, {
exclude: /node_modules/, test: /\.(jpg|png|gif|svg|ico)$/,
use: { exclude: /node_modules/,
loader: 'file-loader', use: {
options: { loader: 'file-loader',
context: 'app/Resources/static', options: {
name: '[path][name].[ext]', context: 'app/Resources/static',
}, name: '[path][name].[ext]',
}, },
}, },
{ },
test: /\.(eot|ttf|woff|woff2)$/, {
use: { test: /\.(eot|ttf|woff|woff2)$/,
loader: 'file-loader', use: {
options: { loader: 'file-loader',
name: 'fonts/[name].[ext]', options: {
}, name: 'fonts/[name].[ext]',
}, },
}, },
], },
}, ],
}); },
}; });

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