forked from moromis/clustergrammer-gl
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.js
76 lines (73 loc) · 1.83 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
const DEBUG = process.argv.indexOf("-p") === -1;
const webpack = require("webpack");
const BrowserSyncPlugin = require("browser-sync-webpack-plugin");
const path = require("path");
const ENTRY_POINT = "./src/main.js";
const filePath = path.join(__dirname, "dist");
const packageFilename = "clustergrammer-gl";
const getConfig = (type, fileExtension, mode, exportType) => ({
entry: ENTRY_POINT,
devtool: DEBUG ? "cheap-module-source-map" : false,
target: "web",
output: {
path: filePath,
filename: `${packageFilename}.${fileExtension}`,
library: {
name: type === "module" ? undefined : "CGM",
type,
...(exportType ? { export: exportType } : {}),
},
},
module: {
rules: [
// This applies the loader to all of your dependencies,
// and not any of the source files in your project:
{
test: /node_modules/,
loader: "ify-loader",
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: "file-loader",
options: {},
},
],
},
],
},
mode,
});
module.exports = [
{
...getConfig("var", "js", "development"),
plugins: [
new BrowserSyncPlugin({
// browse to http://localhost:3100/ during development,
// ./example directory is being served
host: "localhost",
port: 3100,
server: {
baseDir: ".",
index: "example/index.html",
},
}),
],
},
getConfig("var", "min.js", "production"),
getConfig("commonjs2", "node.js", "development"),
getConfig("commonjs2", "node.min.js", "production"),
{
...getConfig("module", "esm.js", "development"),
experiments: {
outputModule: true,
},
},
{
...getConfig("module", "esm.min.js", "production"),
experiments: {
outputModule: true,
},
},
];