71 lines
2.2 KiB
JavaScript
71 lines
2.2 KiB
JavaScript
// Generated using webpack-cli https://github.com/webpack/webpack-cli
|
|
|
|
const path = require("path");
|
|
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
|
|
const yaml = require('js-yaml');
|
|
|
|
const stylesHandler = MiniCssExtractPlugin.loader;
|
|
|
|
const webpackVersion = require('webpack/package.json').version.split('.').slice(0, 2).join('.');
|
|
|
|
const config = {
|
|
mode: 'production',
|
|
devtool: 'source-map',
|
|
entry: {
|
|
main: [ path.resolve(__dirname, "src", "index.js")
|
|
]
|
|
},
|
|
output: {
|
|
chunkFilename: '[chunkhash].js',
|
|
filename: '[chunkhash].js',
|
|
path: path.resolve(__dirname, 'dist', `wp-${webpackVersion}`),
|
|
publicPath: `/wp-${webpackVersion}/`,
|
|
hashFunction: 'shake256',
|
|
hashDigestLength: 36
|
|
},
|
|
plugins: [
|
|
new WebpackManifestPlugin({
|
|
fileName: path.resolve(__dirname, 'dist', '.manifest.yaml'),
|
|
publicPath: `/wp-${webpackVersion}/`,
|
|
generate: (seed, files, entrypoints) => Object.keys(entrypoints).reduce((acc, fs) => ({...acc, [fs]: files.filter(file => entrypoints[fs].filter(basename => !(/\.map$/.test(basename))).some(basename => file.path.endsWith(basename))).filter(file => file.isInitial).map(file => file.path)}), {}),
|
|
serialize: yaml.dump
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
filename: '[chunkhash].css',
|
|
chunkFilename: '[chunkhash].css',
|
|
}),
|
|
|
|
new RemoveEmptyScriptsPlugin({
|
|
extensions: /\.(js|css|scss|sass|less|styl)([?].*)?$/
|
|
}),
|
|
|
|
// Add your plugins here
|
|
// Learn more about plugins from https://webpack.js.org/configuration/plugins/
|
|
],
|
|
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.s[ac]ss$/i,
|
|
use: [stylesHandler, "css-loader", "postcss-loader", "sass-loader"],
|
|
},
|
|
{
|
|
test: /\.css$/i,
|
|
use: [stylesHandler, "css-loader", "postcss-loader"],
|
|
},
|
|
{
|
|
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
|
|
type: "asset",
|
|
},
|
|
|
|
// Add your rules for custom modules here
|
|
// Learn more about loaders from https://webpack.js.org/loaders/
|
|
],
|
|
},
|
|
};
|
|
|
|
module.exports = config;
|