-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.js
81 lines (76 loc) · 1.91 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
81
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const dist_path = path.resolve(__dirname, 'dist');
let config = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: dist_path,
},
plugins: [
new FaviconsWebpackPlugin('./src/img/marketing_accelerator_favicon.png'),
new HtmlWebpackPlugin({
title: 'Snowflake Inspector by Hashmap',
hash: true,
filename: 'bundle.html',
path: dist_path,
template: './src/html/index.html',
}),
new HtmlWebpackPlugin({
title: 'Hashmap Consent',
hash: true,
filename: 'consent.html',
path: dist_path,
template: './src/html/consent.html',
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new MiniCssExtractPlugin({
filename: 'bundle.css',
}),
new CopyWebpackPlugin({
patterns: [{ from: './src/data/default-data.csv' }],
}),
],
module: {
rules: [
{
test: /\.html$/i,
loader: 'html-loader',
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.(ttf|eot|woff||woff2|otf|svg|png|jpg|gif|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: ['file-loader'],
},
{
test: /\.sql$/,
use: ['raw-loader'],
},
],
},
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'inline-source-map';
config.devServer = {
contentBase: './dist',
hot: true,
port: 9000,
openPage: 'bundle.html',
};
}
if (argv.mode === 'production') {
config.devtool = 'source-map';
}
return config;
};