-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
65 lines (60 loc) · 1.84 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
// All packages, presets, and plugins installed need to be configured here so that webpack
// knows how and what to bundle and what to exclude
// IMPORTS
const path = require('path');
// PLUGINS
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// const CompressionPlugin = require("compression-webpack-plugin");
module.exports = {
// the output bundle won't be optimized for production but suitable for development
mode: 'development',
// Entry Point
entry: path.resolve(__dirname, 'src', 'index.jsx'),
// PLUGINS
plugins: [
new CleanWebpackPlugin(), // clears dist folder after each build
new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'src', 'index.html') }),
new MiniCssExtractPlugin({ filename: './src/styles/styles.css' }),
// new CompressionPlugin(),
],
// Output
output: {
// the output of the webpack build will be in /dist directory
path: path.resolve(__dirname, 'src', 'dist'),
// the filename of the JS bundle will be bundle.js
filename: 'bundle.js',
},
// devtool helps identify where error is happening
devtool: 'inline-source-map',
module: {
rules: [
// webpack needs to know that js and jsx files need to go through babel before being bundled
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
// sass loader
{
test: /\.(sass|scss)$/,
use: [
MiniCssExtractPlugin.loader, // do we need both?
{
loader: 'css-loader',
},
{
loader: 'sass-loader',
},
],
},
],
},
// Resolve extension issues
resolve: {
extensions: ['.js', '.jsx'],
},
};