-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
69 lines (67 loc) · 2.22 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
process.traceDeprecation = true;
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackHashFilePlugin = require('./buildtools/WebpackHashFilePlugin'); // Our custom plugin found in `/buildtools`
const devMode = process.env.NODE_ENV !== 'production';
const plugins = [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: devMode ? '[name].css' : '[name].[fullhash].css',
chunkFilename: devMode ? '[id].css' : '[id].[fullhash].css',
}),
new WebpackHashFilePlugin({
path: '../_data/',
fileName: 'hash.yml'
}), // HASH IS USED TO KICK-OFF JEKYLL
];
module.exports = {
mode: devMode ? 'development' : 'production',
plugins,
entry: './assets/js/src/all.js',
output: {
filename: '[name].[fullhash].bundle.js',
path: path.resolve(__dirname, 'assets', 'js', 'dist'),
// `publicPath` tells webpack where to look for modules on the server
publicPath: 'auto', // publicPath may need adjustment when bringing this site into core.
clean: true,
},
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: { // Do not let css-loader resolve `url()`s
url: false, // Will throw errors when trying to resolve url() for local assets if set to default (true)
},
},
'postcss-loader',
'sass-loader',
],
},
{
test: /\.js$/,
exclude: [
path.resolve(__dirname, 'node_modules')
],
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true, // Cache the babel compilation // Cached files are stored & gzipped in `/node_modules/.cache/babel-loader/`
// Set a custom `cacheIdentifier: '<my_custom_cache_identifier>',` SHOULD you need to manually bust the babel-loader cache.
},
},
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff)$/i,
type: 'asset/resource'
},
]
},
resolve: {
extensions: ['.json', '.js', '.jsx']
}
};