Fixed webpack options
This commit is contained in:
parent
96c95a8649
commit
0d11abb1aa
|
@ -4,7 +4,7 @@ const path = require('path');
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
const entry = './src/js/app.js';
|
const entry = './src/js/app.js';
|
||||||
|
@ -15,7 +15,7 @@ let outputPath = path.join(__dirname, 'src/public/js');
|
||||||
|
|
||||||
module.exports = env => {
|
module.exports = env => {
|
||||||
// Dev environment
|
// Dev environment
|
||||||
let devtool = 'eval';
|
let devtool = 'inline-source-map';
|
||||||
let mode = 'development';
|
let mode = 'development';
|
||||||
let stats = 'minimal';
|
let stats = 'minimal';
|
||||||
let plugins = [
|
let plugins = [
|
||||||
|
@ -53,7 +53,8 @@ module.exports = env => {
|
||||||
// the url to the output directory resolved relative to the HTML page
|
// the url to the output directory resolved relative to the HTML page
|
||||||
publicPath: 'js',
|
publicPath: 'js',
|
||||||
// the filename template for entry chunks
|
// the filename template for entry chunks
|
||||||
filename: 'app.js'
|
filename: '[name].bundle.js',
|
||||||
|
chunkFilename: '[name].bundle.js',
|
||||||
},
|
},
|
||||||
|
|
||||||
// Webpack 4 mode helper
|
// Webpack 4 mode helper
|
||||||
|
@ -125,7 +126,7 @@ module.exports = env => {
|
||||||
devtool,
|
devtool,
|
||||||
|
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: 'src/public'
|
static: 'src/public',
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: plugins.concat(
|
plugins: plugins.concat(
|
||||||
|
@ -142,13 +143,10 @@ module.exports = env => {
|
||||||
),
|
),
|
||||||
|
|
||||||
optimization: {
|
optimization: {
|
||||||
|
minimize: true,
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin(),
|
||||||
cache: true,
|
new OptimizeCSSAssetsPlugin()
|
||||||
parallel: true,
|
|
||||||
sourceMap: true // set to true if you want JS source maps
|
|
||||||
}),
|
|
||||||
new OptimizeCSSAssetsPlugin({})
|
|
||||||
],
|
],
|
||||||
runtimeChunk: 'single',
|
runtimeChunk: 'single',
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
|
|
Loading…
Reference in New Issue