-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
53 lines (49 loc) · 1.47 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
const path = require("path");
var config = {
// entry is the "main" source file we want to include/import
entry: __dirname + "/src/trove.js",
// output tells webpack where to put the bundle it creates
output: {
path: path.resolve(__dirname, "dist"),
// in the case of a "plain global browser library", this
// will be used as the reference to our module that is
// hung off of the window object.
library: "Trove",
// We want webpack to build a UMD wrapper for our module
libraryTarget: "umd",
// the destination file name
filename: "trove-api.js",
umdNamedDefine: true
},
// externals let you tell webpack about external dependencies
// that shouldn't be resolved by webpack.
externals: [
{
}
],
module: {
rules: [
{
// babel loader, testing for files that have a .js extension
// (except for files in our node_modules folder!).
test: /\.js$/,
exclude: [
path.resolve(__dirname, "node_modules")
],
loader: "babel-loader"
}
],
}
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
// config.mode = "development";
config.devtool = 'source-map';
config.output.filename = "trove-api.js";
}
if (argv.mode === 'production') {
// config.mode = "production";
config.output.filename = "trove-api.min.js";
}
return config;
};