-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
52 lines (51 loc) · 1.68 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
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = (env, argv) => ({
mode: argv.mode || 'development',
entry: './src/index.js',
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, './dist'),
publicPath: argv.mode === 'production' ? './' : '/',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/env', // This compiles es6, 7, 8, 9, 10 down to es5 - Supports lates javascript standard given in ecma script.
{
useBuiltIns: 'usage', // alternative mode: "entry"
corejs: 3, // default would be 2
targets: '> 0.25%, not dead',
// set your own target environment here (see Browserslist)
},
],
],
plugins: [
'@babel/plugin-proposal-class-properties', // This is for using features like class properties for the ability to directly declare properties inside the class and not the constructor. It is used by react.
],
},
},
},
{
test: /\.css$/,
use: [
'style-loader', // Adds the style to the DOM
'css-loader', // Reads the CSS
],
},
],
},
plugins: [
new CleanWebpackPlugin(), // Cleans the dist folder before the build
new HtmlWebpackPlugin({
template: 'public/index.html',
}), // Generates HTML file along with the other files
],
});