-
Notifications
You must be signed in to change notification settings - Fork 28
/
webpack.common.js
171 lines (168 loc) · 4.26 KB
/
webpack.common.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
require('@babel/register');
const path = require('path');
const webpack = require('webpack');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const config = require('./app/src/js/config');
const CommonConfig = {
target: 'web',
entry: [
'core-js/stable',
'regenerator-runtime/runtime',
'./app/src/index.js',
],
output: {
filename: 'bundle.js',
chunkFilename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
optimization: {
moduleIds: 'deterministic',
},
resolve: {
extensions: ['.js', '.jsx', '.scss'],
alias: {
Fonts: path.join(__dirname, 'app/src/assets/fonts'),
Images: path.join(__dirname, 'app/src/assets/images'),
},
fallback: {
fs: false,
net: false,
tls: false,
console: require.resolve('console-browserify'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
crypto: require.resolve('crypto-browserify'),
util: require.resolve('util'),
vm: require.resolve('vm-browserify'),
},
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: [
/node_modules\/(?!(map-obj|snakecase-keys|strict-uri-encode|fast-xml-parser)\/).*/,
/font-awesome.config.js/,
],
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
],
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
},
],
},
{
test: /\.(css|scss)$/,
use: [
{
loader: 'css-loader', // Translates CSS into CommonJS
options: {
sourceMap: true,
importLoaders: 1,
},
},
{
loader: 'resolve-url-loader',
options: {
sourceMap: true,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-loader', // Compiles Sass to CSS
options: {
sourceMap: true,
},
},
],
},
{
test: /\.(woff|woff2|eot|ttf|svg)(\?[a-z0-9=.]+)?$/, // fonts
use: {
loader: 'file-loader',
options: {
name: '[path][name].[hash].[ext]',
outputPath: 'fonts/',
publicPath: '../',
},
},
},
{
test: /\.(jpe?g|png|gif|ico|svg)(\?[a-z0-9=.]+)?$/, // images/graphics
use: {
loader: 'file-loader',
options: {
name: '[path][name].[hash].[ext]',
outputPath: 'images/',
publicPath: '../',
},
},
},
{
test: /font-awesome\.config\.js/,
use: [
{
loader: 'style-loader',
},
{
loader: 'font-awesome-loader',
},
],
},
{
test: /\.m?js$/,
include: /node_modules/,
type: 'javascript/auto',
resolve: {
fullySpecified: false
}
},
],
},
plugins: [
new HtmlWebPackPlugin({
template: path.join(__dirname, 'app/src/template.html'),
filename: 'index.html',
title: 'Cumulus Dashboard',
favicon: './app/src/public/favicon.ico'
}),
new CopyWebpackPlugin({
patterns: [{ from: './app/src/public', to: './' }],
}),
new webpack.ProvidePlugin({
jQuery: 'jquery', // can use jquery anywhere in the app without having to require it
$: 'jquery',
process: 'process/browser',
}),
new webpack.EnvironmentPlugin({
APIROOT: config.apiRoot,
AWS_REGION: config.awsRegion,
DAAC_NAME: config.target,
STAGE: config.environment,
HIDE_PDR: config.nav.exclude.PDRs,
AUTH_METHOD: config.oauthMethod,
KIBANAROOT: config.kibanaRoot,
BUCKET: config.graphicsPath,
ENABLE_RECOVERY: config.enableRecovery,
SERVED_BY_CUMULUS_API: config.servedByCumulusAPI,
}),
],
};
module.exports = CommonConfig;