-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathwebpack.config.js
More file actions
44 lines (39 loc) · 898 Bytes
/
webpack.config.js
File metadata and controls
44 lines (39 loc) · 898 Bytes
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
const path = require('path');
const webpack = require('webpack');
const root = process.cwd();
const { NODE_ENV } = process.env;
const packageName = process.env.npm_package_name;
const config = {
mode: NODE_ENV === 'production' ? 'production' : 'development',
context: root,
devtool: 'source-map',
entry: './src/index.js',
output: {
filename: `${packageName}.js`,
path: path.join(root, 'dist'),
library: 'TinyOSS',
libraryTarget: 'umd',
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
}),
],
module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
},
],
},
],
},
};
if (NODE_ENV === 'production') {
config.output.filename = `${packageName}.min.js`;
}
module.exports = config;