-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
70 lines (67 loc) · 1.72 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPkgJsonPlugin = require('copy-pkg-json-webpack-plugin');
const pkg = require('./package.json');
const webpack = require('webpack');
const path = require('path');
const name = 'board-generator';
let plugins = [new CopyPkgJsonPlugin({
new: {
name: pkg.name,
author: pkg.author,
description: pkg.description,
version: pkg.version,
main: `${name}.min.js`,
license: 'MIT',
dependencies: {},
devDependencies: pkg.devDependencies
}
})];
module.exports = (env = {}) => {
if (env.production) {
plugins.push(new webpack.BannerPlugin(`${name} - ${pkg.version}`));
} else {
plugins.push(new HtmlWebpackPlugin({
template: 'index.html'
}));
}
return {
mode: env.production ? 'production' : 'development',
entry: './src',
output: {
path: __dirname + '/lib',
publicPath: path.resolve(__dirname, '/lib/'),
filename: `${name}.min.js`,
library: 'BoardGenerator',
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: 'typeof self !== \'undefined\' ? self : this'
},
devServer: {
contentBase: path.resolve(__dirname, './'),
publicPath: path.resolve(__dirname, '/lib/')
},
module: {
rules: [
{
test: /\.json/,
use: {loader: 'file-loader', options: {context: path.resolve(__dirname)}}
},
{
test: /\.worker\.js$/,
use: {
loader: 'worker-loader',
options: {
inline: true
}
}
},
{
test: /\.js$/,
loader: 'babel-loader',
include: /src/
}
]
},
plugins: plugins
};
};