const path = require('path'); const webpack = require('webpack'); const CopyPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { mode: 'production', entry: { index: './index.js' }, output: { filename: '[name].[contenthash].js', path: path.resolve(__dirname, 'dist'), publicPath: '' }, module: { rules: [ { test: /\.css$/, loaders: [MiniCssExtractPlugin.loader, "css-loader"] }, { test: { and: [ /\.(jpe?g|png|gif|svg)$/i, /jquery-ui/i ] }, loader: "file-loader", options: { name: '[name].[contenthash].[ext]', outputPath: 'assets/jquery-ui' } }, { test: { and: [ /\.(jpe?g|png|gif|mp3|wav)$/i, { not: [ /jquery-ui/i ] } ] }, loader: "file-loader", options: { name: '[path][name].[contenthash].[ext]', outputPath: 'assets/' } }, { test: { and: [ /\.svg$/i, { not: [ /jquery-ui/i ] } ] }, use: [ { loader: "file-loader", options: { name: '[path][name].[contenthash].[ext]', outputPath: 'assets/' } }, { loader: "svgo-loader" } ] }, { test: /(^|[/\\])manifest.js$/i, use: [ { loader: "file-loader", options: { name: "[path]manifest.webmanifest", }, }, "extract-loader" ], }, ] }, plugins: [ new CleanWebpackPlugin(), new HtmlWebpackPlugin({ title: 'Paco Ŝako', template: 'index.html', }), new MiniCssExtractPlugin({ filename: '[name].[contenthash].css', chunkFilename: '[id].[contenthash].css', }), new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", "window.jQuery": "jquery'", "window.$": "jquery" }), new CopyPlugin([ { from: '.htaccess' }, { from: 'sw.js' }, ]), ], optimization: { moduleIds: 'hashed', splitChunks: { chunks: 'all', cacheGroups: { vendor: { test: /[\\/]node_modules[\\/]/, name: 'vendors', chunks: 'all', }, }, }, }, }; /* vim:set expandtab sw=2 ts=8: */