updated wepack config file syntax

This commit is contained in:
andres alcocer
2021-10-06 13:33:22 -04:00
parent dec38a4ff7
commit 35f64a58f8
2 changed files with 17 additions and 8 deletions

View File

@@ -1,2 +1,3 @@
client/dist/ client/dist/
node_modules/ node_modules/
webpack.config.js

View File

@@ -1,7 +1,7 @@
const HtmlWebPackPlugin = require('html-webpack-plugin'); const HtmlWebPackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const dotenv = require('dotenv'); const dotenv = require('dotenv');
const webpack = require('webpack'); const webpack = require('webpack');
var path = require('path'); var path = require('path');
@@ -42,7 +42,7 @@ module.exports = () => {
{ {
test: /\.css$/, test: /\.css$/,
include: /node_modules/, include: /node_modules/,
loaders: ['style-loader', 'css-loader'], use: ['style-loader', 'css-loader'],
}, },
{ {
test: /\.scss$/, test: /\.scss$/,
@@ -76,7 +76,7 @@ module.exports = () => {
historyApiFallback: true, historyApiFallback: true,
}, },
node: { node: {
fs: 'empty', global: true,
}, },
plugins: [ plugins: [
new webpack.DefinePlugin(envKeys), new webpack.DefinePlugin(envKeys),
@@ -84,15 +84,23 @@ module.exports = () => {
template: './src/index.html', template: './src/index.html',
filename: './index.html', filename: './index.html',
}), }),
new CopyWebpackPlugin([ // new CopyWebpackPlugin({
{ from: 'src/static/images', to: 'static/images' }, // patterns: [[ { from: 'src/static/images', to: 'static/images' }],
]), // }),
new CopyWebpackPlugin({
patterns: [
{
from: 'src/static/images',
to: 'static/images',
},
],
}),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output // Options similar to the same options in webpackOptions.output
// both options are optional // both options are optional
filename: 'main.css', filename: 'main.css',
}), }),
new CleanWebpackPlugin(['dist']), new CleanWebpackPlugin(),
], ],
}; };
}; };