This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
webpack.config.js
111 lines (110 loc) · 3.13 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
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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CSSMinimizerPlugin = require('css-minimizer-webpack-plugin');
const sass = require("sass");
const pkg = require('./package.json');
module.exports = {
entry: {
index: './src/index.js',
styles: './src/styles/index.scss'
},
devtool: false,
externals: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),
"react",
"react-dom"
],
mode: 'production',
module: {
rules: [{
test: /\.m?jsx?$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader'
},
resolve: {
fullySpecified: false
}
},
{
test: /\.scss$/,
use: [{
loader: MiniCssExtractPlugin.loader
},
'css-loader', // translates CSS into CommonJS
{
loader: 'sass-loader',
options: {
implementation: sass
}
}
]
},
{
test: /\.css$/,
use: [{
loader: MiniCssExtractPlugin.loader
},
'css-loader' // translates CSS into CommonJS
]
},
{
test: /\.(png|jpg|gif)$/i,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'icons'
}
}]
},
{
test: /\.(ttf|otf|woff|woff2|eot)$/i,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts'
}
}]
}
]
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
exclude: /\/node_modules/,
parallel: true
}),
new CSSMinimizerPlugin()
]
},
output: {
libraryTarget: 'commonjs2',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: '[name].css',
chunkFilename: '[id].css'
})
],
resolve: {
alias: {
"react-dnd": path.resolve("node_modules/react-dnd"),
"react/jsx-runtime": "react/jsx-runtime.js",
"react/jsx-dev-runtime": "react/jsx-dev-runtime.js"
},
extensions: [".js", ".jsx"],
fallback: {
crypto: false,
fs: false,
path: false
}
}
};