This repository was archived by the owner on Apr 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
95 lines (92 loc) · 2.63 KB
/
Copy pathwebpack.config.js
File metadata and controls
95 lines (92 loc) · 2.63 KB
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 path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {SvgMapGeneratorPlugin} = require('./webpack/svg_map/svg_map_generator_plugin');
let config = {
entry: {
main: './src/js/index.js',
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
optimization: {
splitChunks: {
chunks: 'all'
}
},
plugins: [
new HtmlWebpackPlugin({
title: "Corbin's Covid Charting",
template: __dirname + '/src/index-template.html'
}),
new SvgMapGeneratorPlugin({
normalizers: [
{
test: /^GA$/,
file: path.resolve('webpack/svg_map/normalize-GA.js')
},
{
test: /^US$/,
file: path.resolve('webpack/svg_map/normalize-US.js')
}
]
}
)
],
target: "web",
mode: "development",
devtool: 'source-map',
resolve: {
alias: {
Maps: path.resolve(__dirname, 'generated/maps'),
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
},
{
test: /\.svg-map$/,
exclude: /node_modules/,
use: [
{
loader: path.resolve('webpack/svg_map/svg_map_generator_plugin.js'),
options: {
}
}
]
},
],
},
};
module.exports = function(env, argv) {
console.log(`MODE: ${argv.mode}`)
let copyPatterns = [
{ from: '**/*.{svg,jpg,png,css}', to: '.', context: path.resolve(__dirname, 'src', 'web')},
]
if (argv.mode === 'development') {
copyPatterns.push({from:'api/data/GA-By-County.json', to: './api/data', context: path.resolve(__dirname, 'src', 'web')})
}
if (argv.mode === 'production') {
config.performance = {
hints: false
}
}
config.plugins.push(new CopyPlugin({patterns: copyPatterns}))
return config
}