-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
70 lines (63 loc) · 1.85 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const path = require("path");
const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: 'production',
context: __dirname,
entry: {
init: ['./assets/js/init.js'],
main: ['./assets/js/application.js', './assets/stylesheets/application.scss'],
peoplefinder: ['./assets/js/peoplefinder.js'],
},
output: {
path: path.resolve('./assets/webpack_bundles/'),
publicPath: '/static/webpack_bundles/',
filename: "[name]-[contenthash].js",
// Access exports using DW.[entry].[export] format, e.g. `DW.peoplefinder.Cropper`.
library: ["DW", "[name]"],
},
plugins: [
new BundleTracker({ filename: './webpack-stats.json' }),
new MiniCssExtractPlugin({
filename: '[name]-[contenthash].css',
chunkFilename: '[id]-[contenthash].css'
})
],
module: {
rules: [
// Copy all images and fonts to the output directory ignoring moj assets
{
test: /\.(png|jpe?g|gif|woff2?|svg|ico|webp)$/i,
exclude: /@ministryofjustice\/frontend\/moj\/assets\/.*\.(png|jpe?g|gif|svg)$/i,
type: 'asset/resource',
generator: {
filename: '[name][ext]',
},
},
// Copy MOJ assets into a custom output directory
{
test: /@ministryofjustice\/frontend\/moj\/assets\/.*\.(png|jpe?g|gif|svg|webp)$/i,
type: 'asset/resource',
generator: {
filename: 'moj/[name][ext]',
},
},
// Extract compiled SCSS separately from JS
{
test: /\.(s[ac]ss|css)$/i,
use: [
{
loader: MiniCssExtractPlugin.loader
},
'css-loader',
'sass-loader'
]
}
]
},
resolve: {
modules: ['node_modules'],
extensions: ['.js', '.scss']
}
}