|
@@ -7,9 +7,17 @@ const TerserPlugin = require('terser-webpack-plugin');
|
|
|
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
|
|
+const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
+
|
|
|
+const publicDir = path.resolve(__dirname, '../dist/public');
|
|
|
+const clientDir = path.resolve(__dirname, '../client');
|
|
|
|
|
|
module.exports = merge(baseWpConfig, {
|
|
|
mode: 'production',
|
|
|
+ output: {
|
|
|
+ path: `${publicDir}/app`,
|
|
|
+ filename: 'bundle.[contenthash].js'
|
|
|
+ },
|
|
|
module: {
|
|
|
rules: [
|
|
|
{
|
|
@@ -32,9 +40,13 @@ module.exports = merge(baseWpConfig, {
|
|
|
]
|
|
|
},
|
|
|
plugins: [
|
|
|
- new CleanWebpackPlugin([`${baseWpConfig.output.path}/*.*`], {root: path.resolve(__dirname, '..')}),
|
|
|
+ new CleanWebpackPlugin([`${publicDir}`], {root: path.resolve(__dirname, '..')}),
|
|
|
new MiniCssExtractPlugin({
|
|
|
- filename: "[name].css"
|
|
|
+ filename: "[name].[contenthash].css"
|
|
|
+ }),
|
|
|
+ new HtmlWebpackPlugin({
|
|
|
+ template: `${clientDir}/index.html.template`,
|
|
|
+ filename: `${publicDir}/index.html`
|
|
|
})
|
|
|
]
|
|
|
});
|