-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
42 lines (40 loc) · 1.36 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
/* global __dirname */
const webpack = require('webpack');
const isProd = (process.env.NODE_ENV === 'production');
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
// minimize only in production
const plugins = isProd ? [new UglifyJSPlugin({ sourceMap: true })] : []
module.exports = {
entry: ["@babel/polyfill", "./src/widget.js"],
output: {
path: path.resolve(__dirname, 'build'),
filename: 'widget.js',
library: 'Widget',
libraryTarget: 'umd'
},
devtool: isProd ? '#source-map' : '#eval-source-map',
externals: {
// require("solid-auth-client") is external and available
// on the global var authClient
// this is how peer dependencies are specified
// in webpack (we need authClient but we do not include in bundle)
"authClient": {
root: "solid-auth-client", // in browser <script> this will resolve in this.fileClient
commonjs2: "solid-auth-client", // require('solid-auth-client')
commonjs: "solid-auth-client", // require('solid-auth-client')
amd: "solid-auth-client" // define(['solid-auth-client'], ...)
}
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: { presets: ['@babel/preset-env'] },
}
}
]
},
plugins: plugins
};