-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
94 lines (88 loc) · 2 KB
/
webpack.config.js
File metadata and controls
94 lines (88 loc) · 2 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
const path = require("path");
const isProduction = process.env.NODE_ENV === "production";
const stylesHandler = "style-loader";
const NODE_ENV = process.env.NODE_ENV || "development";
const outFilename = `index.${NODE_ENV}.js`;
console.log(`Building ${NODE_ENV}...`);
const config = {
entry: "./src/index.js",
output: {
library: "ReactCashmere",
libraryTarget: "umd",
filename: outFilename,
path: path.resolve(__dirname, "dist"),
},
plugins: [],
externals: [
/^@mui\/*/, // Don't bundle any mui libraries
{
// Don't bundle react or react-dom
react: {
commonjs: "react",
commonjs2: "react",
amd: "React",
root: "React",
},
"react-dom": {
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "ReactDOM",
root: "ReactDOM",
}
},
],
module: {
rules: [
{
test: /\.jsx?$/,
use: ["babel-loader"],
exclude: ["/node_modules/", "/public/", "/src/stories"],
},
{
test: /\.css$/i,
use: [stylesHandler, "css-loader"],
},
{
test: /\.s[ac]ss$/i,
use: [
stylesHandler,
{
loader: "css-loader",
options: {
importLoaders: 1,
modules: {
localIdentName: '[name]',
mode: "global",
},
},
},
{
loader: "sass-loader",
options: {
implementation: require("sass"),
},
},
],
},
{
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
type: "asset",
generator: {
filename: "./fonts/[name][ext]",
},
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".jsx", ".js", "..."],
},
};
module.exports = () => {
if (isProduction) {
config.mode = "production";
} else {
config.mode = "development";
config.devtool = "source-map";
}
return config;
};