-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
86 lines (77 loc) · 1.89 KB
/
webpack.config.js
File metadata and controls
86 lines (77 loc) · 1.89 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
require('dotenv').config();
// Dynamic Script and Style Tags
const HTMLPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const devMode = process.env.NODE_ENV !== 'production'
const CopyWebpackPlugin = require('copy-webpack-plugin');
const plugins = [
new HTMLPlugin({
template: `${__dirname}/src/index.html`,
}),
new MiniCssExtractPlugin('bundle.[hash].css'),
new CopyWebpackPlugin([{
flatten: true,
from: 'src/data/*',
to: 'data',
},
{from: 'src/assets/images', to: 'images'}
])
];
module.exports = {
plugins,
// Load this and everythning it cares about
entry: `${__dirname}/src/script.js`,
devtool: 'source-map',
// Stick it into the "path" folder with that file name
output: {
filename: 'bundle.[hash].js',
path: `${__dirname}/build`,
},
module: {
rules: [
// If it's a .js file not in node_modules, use the babel-loader
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
// If it's a .scss file
{
test: /\.scss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.(woff|woff2|ttf|eot|glyph|\.svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 10000,
name: 'font/[name].[ext]',
},
},
],
},
{
test: /\.(jpg|jpeg|gif|png|tiff|svg)$/,
exclude: /\.glyph.svg/,
use: [
{
loader: 'url-loader',
options: {
limit: 6000,
name: 'images/[name].[ext]',
},
},
],
},
],
},
devServer: {
historyApiFallback: true,
},
};