-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
59 lines (54 loc) · 1.25 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
const path = require('path');
const htmlLoaderRule = {
test: /\.html$/i,
use: {
loader: 'html-loader',
options: {
attrs: false,
interpolate: true,
},
},
};
const cssLoaderRule = {
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
};
/**
* We need two different configs for two js builds.
* webConfig for creating a compiled JS file that can be included directly with a <script> tag.
* nodeConfig for compiling a JS module to be distributed via npm.
*/
const webConfig = {
entry: ['@babel/polyfill', './src/browser-entrypoint.js'],
mode: 'development',
module: {
rules: [{
exclude: /node_modules/,
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
}, htmlLoaderRule, cssLoaderRule],
},
output: {
filename: 'user-feedback-form.js',
path: path.resolve(__dirname, 'dist'),
},
};
const nodeConfig = {
entry: ['./src/index.js'],
mode: 'development',
module: {
rules: [htmlLoaderRule, cssLoaderRule],
},
output: {
filename: 'index.js',
library: 'userFeedbackForm',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'dist'),
},
};
module.exports = [webConfig, nodeConfig];