|
|
|
@ -2,62 +2,78 @@ const path = require('path');
|
|
|
|
|
|
|
|
|
|
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
|
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
|
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
|
|
|
|
const webpack = require('webpack');
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
mode: 'development',
|
|
|
|
|
entry: {
|
|
|
|
|
index: './src/index.js'
|
|
|
|
|
},
|
|
|
|
|
output: {
|
|
|
|
|
filename: '[name].bundle.js',
|
|
|
|
|
path: path.resolve(__dirname, '../dist')
|
|
|
|
|
},
|
|
|
|
|
module.exports = env => {
|
|
|
|
|
return {
|
|
|
|
|
// mode: 'production',
|
|
|
|
|
// devtool: 'source-map',
|
|
|
|
|
// entry: {
|
|
|
|
|
// index: './src/index.js'
|
|
|
|
|
// },
|
|
|
|
|
// output: {
|
|
|
|
|
// filename: '[name].bundle.js',
|
|
|
|
|
// path: path.resolve(__dirname, '../dist')
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
test: /\.s?css$/,
|
|
|
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
|
|
|
loader: "file-loader",
|
|
|
|
|
options: {
|
|
|
|
|
name: '[name].[ext]',
|
|
|
|
|
outputPath: 'font/'
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
test: /\.s?css$/,
|
|
|
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
|
|
|
type: 'asset/resource'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
|
filename: '[name].css'
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
stats: {
|
|
|
|
|
orphanModules: true
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
devServer: {
|
|
|
|
|
contentBase: './dist',
|
|
|
|
|
hot: true
|
|
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
fallback: {
|
|
|
|
|
util: require.resolve("util/")
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
optimization: {
|
|
|
|
|
splitChunks: {
|
|
|
|
|
cacheGroups: {
|
|
|
|
|
commons: {
|
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
|
name: 'vendors',
|
|
|
|
|
chunks: 'all'
|
|
|
|
|
},
|
|
|
|
|
styles: {
|
|
|
|
|
name: 'styles',
|
|
|
|
|
test: /\.css$/,
|
|
|
|
|
chunks: 'all',
|
|
|
|
|
enforce: true,
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
// new ProgressBarPlugin(),
|
|
|
|
|
// new CleanWebpackPlugin(),
|
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
|
filename: '[name].css'
|
|
|
|
|
}),
|
|
|
|
|
new webpack.EnvironmentPlugin({
|
|
|
|
|
DEBUG: false,
|
|
|
|
|
NODE_DEBUG: false,
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
//
|
|
|
|
|
// devServer: {
|
|
|
|
|
// contentBase: './dist',
|
|
|
|
|
// hot: true
|
|
|
|
|
// },
|
|
|
|
|
//
|
|
|
|
|
optimization: {
|
|
|
|
|
usedExports: true,
|
|
|
|
|
splitChunks: {
|
|
|
|
|
cacheGroups: {
|
|
|
|
|
commons: {
|
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
|
name: 'vendors',
|
|
|
|
|
chunks: 'all'
|
|
|
|
|
},
|
|
|
|
|
styles: {
|
|
|
|
|
name: 'styles',
|
|
|
|
|
test: /\.css$/,
|
|
|
|
|
chunks: 'all',
|
|
|
|
|
enforce: true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|