-
Notifications
You must be signed in to change notification settings - Fork 34
/
webpack.config.dev.js
95 lines (92 loc) · 2.61 KB
/
webpack.config.dev.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const assert = require('assert');
const path = require('path');
const { existsSync } = require('fs');
const webpack = require('webpack');
const exec = require('child_process').exec;
const WebpackWatchPlugin = require('webpack-watch-files-plugin').default;
const env = process.env.APP_ENV || 'development';
const settings$ = path.join(__dirname, 'js', 'settings', `${env}.js`);
assert(existsSync(settings$), `${env} is not an acceptable environment.`);
module.exports = {
mode: 'development',
devtool: 'eval-source-map',
watchOptions: {
ignored: /node_modules/,
},
plugins: [
// Needed to watch SCSS folders since not importing from JS file will not trigger webpack
new WebpackWatchPlugin({
files: [
'www.foia.gov/*',
'www.foia.gov/**/*.*',
'js/**/*.*',
],
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
{
// Webpack Watch triggers when change is made, and rebuilds the site using Jekyll
apply: (compiler) => {
compiler.hooks.watchRun.tap('WatchRun', () => {
exec('make build.reload', (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
});
});
},
},
],
entry: {
landing: './js/landing.jsx',
glossary: './js/glossary.js',
request: './js/request.jsx',
uswds: './js/uswds.js',
contact_download: './js/contact_download.jsx',
annual_report_data: './js/annual_report_data.jsx',
quarterly_report_data: './js/quarterly_report_data.jsx',
chief_foia_officers_council: './js/chief_foia_officers_council.jsx',
wizard: './js/wizard.jsx',
agency_search: './js/agency_search.jsx',
},
output: {
path: path.resolve(__dirname, 'www.foia.gov/assets/js'),
filename: '[name].bundle.js',
},
module: {
rules: [
// Some contributed code needs to be transpiled first.
{
include: /(excellentexport.js)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
compact: false,
},
},
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.json'],
modules: [path.join(__dirname, 'js'), 'node_modules'],
alias: {
settings$,
},
},
};