-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathwebpack.config.js
More file actions
117 lines (104 loc) · 2.31 KB
/
webpack.config.js
File metadata and controls
117 lines (104 loc) · 2.31 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
require('dotenv').config();
// Dynamic Script and Style Tags
const HTMLPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
// Makes a separate CSS bundle
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const plugins = [
new HTMLPlugin({
template: `${__dirname}/src/index.html`,
}),
new MiniCssExtractPlugin({ filename: 'bundle.[hash].css' }),
new CopyWebpackPlugin([
{
flatten: true,
from: 'src/assets/downloads/*',
to: 'downloads',
},
{
from: 'src/CNAME',
},
{
flatten: true,
from: 'src/assets/images',
to: 'images',
},
{
flatten: true,
from: 'data',
to: 'data',
},
]),
];
module.exports = {
plugins,
// Load this and everythning it cares about
entry: `${__dirname}/src/main.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: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
'resolve-url-loader',
{
loader: 'sass-loader',
options: {
includePaths: [`${__dirname}/src/style`],
sourceMap: true,
},
},
],
},
{
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,
},
};