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, '../../../');
module.exports = function () {
return {
entry: {
material: path.join(rootDir, './app/Resources/static/themes/material/index.js'),
baggy: path.join(rootDir, './app/Resources/static/themes/baggy/index.js'),
public: path.join(rootDir, './app/Resources/static/themes/_global/share.js'),
module.exports = {
entry: {
material: path.join(rootDir, './app/Resources/static/themes/material/index.js'),
baggy: path.join(rootDir, './app/Resources/static/themes/baggy/index.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 commonConfig = require('./common.js');
module.exports = function () {
return merge(commonConfig(), {
devtool: 'eval-source-map',
output: {
filename: '[name].dev.js',
},
mode: 'development',
devServer: {
hot: true,
// enable HMR on the server
contentBase: './web',
// match the output path
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
},
module.exports = merge(commonConfig, {
devtool: 'eval-source-map',
output: {
filename: '[name].dev.js',
},
mode: 'development',
devServer: {
hot: true,
// enable HMR on the server
contentBase: './web',
// match the output path
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
module: {
rules: [
{
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: /\.(s)?css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
{
test: /\.(s)?css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: ['autoprefixer'],
},
},
{
loader: 'postcss-loader',
options: {
plugins: [require('autoprefixer')({})],
},
},
'sass-loader',
],
},
{
test: /\.(jpg|png|gif|svg|ico|eot|ttf|woff|woff2)$/,
use: 'url-loader',
},
],
},
});
};
},
'sass-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');
module.exports = function () {
return merge(commonConfig(), {
output: {
filename: '[name].js',
},
mode: 'production',
devtool: 'source-map',
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true,
terserOptions: {
output: {
comments: false,
},
module.exports = merge(commonConfig, {
output: {
filename: '[name].js',
},
mode: 'production',
devtool: 'source-map',
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
output: {
comments: false,
},
extractComments: false,
}),
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
},
}),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new ManifestPlugin({
fileName: 'manifest.json',
extractComments: false,
}),
],
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
},
},
plugins: [
new MiniCssExtractPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new ManifestPlugin({
fileName: 'manifest.json',
}),
],
module: {
rules: [
{
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: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: process.env.NODE_ENV === 'development',
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: ['autoprefixer'],
},
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
plugins: [require('autoprefixer')({})],
},
},
'sass-loader',
],
},
{
test: /\.(jpg|png|gif|svg|ico)$/,
include: /node_modules/,
use: {
loader: 'file-loader',
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/,
use: {
loader: 'file-loader',
options: {
context: 'app/Resources/static',
name: '[path][name].[ext]',
},
},
{
test: /\.(jpg|png|gif|svg|ico)$/,
exclude: /node_modules/,
use: {
loader: 'file-loader',
options: {
context: 'app/Resources/static',
name: '[path][name].[ext]',
},
},
{
test: /\.(eot|ttf|woff|woff2)$/,
use: {
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
},
},
{
test: /\.(eot|ttf|woff|woff2)$/,
use: {
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
},
},
],
},
});
};
},
],
},
});

View File

@ -38,29 +38,32 @@
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"autoprefixer": "^9.8.6",
"autoprefixer": "^10.0.2",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.1",
"css-loader": "^4.3.0",
"css-loader": "^5.0.1",
"eslint": "^7.13.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.22.1",
"file-loader": "^6.2.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",
"postcss-loader": "^3.0.0",
"postcss": "^8.1.6",
"postcss-loader": "^4.0.4",
"sass": "^1.29.0",
"sass-loader": "^10.0.5",
"style-loader": "^2.0.0",
"stylelint": "^7.9.0",
"stylelint-config-standard": "^16.0.0",
"stylelint-webpack-plugin": "^1.0.0",
"stylelint": "^13.7.2",
"stylelint-config-standard": "^20.0.0",
"stylelint-scss": "^3.18.0",
"stylelint-webpack-plugin": "^2.1.1",
"url-loader": "^4.1.1",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12",
"webpack": "^5.4.0",
"webpack-cli": "^4.2.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"
},
"dependencies": {

View File

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

3434
yarn.lock

File diff suppressed because it is too large Load Diff