-
Notifications
You must be signed in to change notification settings - Fork 53
/
webpack.config.js
84 lines (80 loc) · 2.24 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
const path = require("path");
const webpack = require("webpack");
const nodeExternals = require("webpack-node-externals");
const package = require("./package.json");
/**
* cdnBuild is the webpack config for distributing SeqViz to unpkg. It bundles the viewer with all its dependencies.
*/
const cdnBuild = {
entry: path.join(__dirname, "src", "index.ts"),
target: "web",
mode: "production",
module: {
rules: [
{ test: /\.(t|j)sx?$/, loader: "ts-loader", exclude: /node_modules/ },
{ test: /\.js$/, enforce: "pre", loader: "source-map-loader", exclude: /node_modules/ },
],
},
optimization: {
concatenateModules: false,
minimize: true,
nodeEnv: "production",
},
output: {
globalObject: "this",
filename: "seqviz.min.js",
library: {
name: package.name,
type: "umd",
},
path: path.join(__dirname, "dist"),
publicPath: "/dist/",
umdNamedDefine: true,
},
plugins: [
new webpack.BannerPlugin(
`${package.name} - ${package.version} \nprovided and maintained by ${package.author} \nLICENSE MIT`
),
],
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
alias: {
react: path.resolve(__dirname, "node_modules/react"),
"react-dom": path.resolve(__dirname, "node_modules/react-dom"),
},
fallback: {
buffer: require.resolve("buffer"),
fs: false,
net: false,
tls: false,
path: require.resolve("path-browserify"),
string_decoder: require.resolve("string_decoder"),
stream: require.resolve("stream-browserify"),
timers: require.resolve("timers-browserify"),
url: require.resolve("url"),
},
},
};
/**
* npmBuild is the same as CDN build except node_modules are ignored as externals and the output filename differs.
*/
const npmBuild = Object.assign({}, cdnBuild, {
mode: "none",
devtool: "source-map",
optimization: {
minimize: false,
},
output: {
globalObject: "this",
filename: "index.js",
library: {
name: package.name,
type: "umd",
},
path: path.join(__dirname, "dist"),
publicPath: "/dist/",
umdNamedDefine: true,
},
externals: [nodeExternals({ modulesDir: path.join(__dirname, "node_modules") })],
});
module.exports = [cdnBuild, npmBuild];