This repository was archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
46 lines (42 loc) · 1.37 KB
/
webpack.config.js
File metadata and controls
46 lines (42 loc) · 1.37 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
const path = require('path');
const WebpackBundleAnalyzer = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = env => {
const isDevelopment = env.mode === "development";
const makeTarget = (target) => ({
entry: "./src/index.ts",
devtool: 'source-map',
output: {
filename: "polygloat-react." + target + ".js",
path: path.resolve(__dirname, 'dist'),
library: 'polygloat-react',
libraryTarget: target
},
resolve: {
extensions: [".webpack.js", ".web.js", ".ts", ".js", ".tsx"],
},
module: {
rules: [
{
test: /\.jsx?$/,
enforce: 'pre',
use: ['source-map-loader']
},
{
test: /\.tsx?$/,
use: [isDevelopment && "ts-loader" || "babel-loader"],
exclude: [/node_modules/, /lib/],
},
]
},
mode: isDevelopment ? "development" : "production",
plugins: [
//new WebpackBundleAnalyzer()
],
externals: {
react: "react",
"react-dom": "react-dom",
"polygloat/ui": "polygloat/ui"
}
});
return [makeTarget("commonjs"), makeTarget("umd"), makeTarget("window")];
};