-
Notifications
You must be signed in to change notification settings - Fork 34
/
webpack.config.js
80 lines (77 loc) · 2.3 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
71
72
73
74
75
76
77
78
79
80
const assert = require('assert');
const path = require('path');
const webpack = require('webpack');
const env = process.env.APP_ENV || 'development';
assert(['local', 'cloud-gov', 'development', 'staging', 'uat', 'production', 'ddev'].includes(env), `${env} is not an acceptable environment.`);
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? 'source-map' : 'eval-source-map',
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
],
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',
swagger: './js/swagger.jsx',
foia_contact_download: './js/foia_contact_download.jsx',
foia_dataset_download: './js/foia_dataset_download.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$: path.join(__dirname, 'js', 'settings', `${env}.js`),
},
fallback: {
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer'),
},
},
};