-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
77 lines (73 loc) · 1.84 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
const pkg = require("./package.json");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const libraryName = pkg.name;
/**
* produces a UMD bundle of our main index.js script, which will be imported using ES6 import syntax.
*/
const indexConfig = {
entry: "./src/index.js",
output: {
path: __dirname + "/dist",
filename: "index.js",
library: libraryName,
libraryTarget: "umd",
publicPath: "/dist/",
umdNamedDefine: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
],
},
// Don't bundle react
resolve: {
alias: {
react: __dirname + "./node_modules/react",
},
},
externals: {
react: {
commonjs: "react",
commonjs2: "react",
amd: "React",
root: "React",
},
},
};
/**
* produces a default bundle for our examples script, which will be includes via the script tag in the browser.
*/
const exampleConfig = {
entry: "./src/example.js",
output: {
filename: "example.js",
path: __dirname + "/example",
umdNamedDefine: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
],
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: "React Base64 Download - example",
filename: "example.html",
}),
],
};
module.exports = [exampleConfig, indexConfig];