-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebpack.config.js
85 lines (82 loc) · 1.64 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
78
79
80
81
82
83
84
85
var pkg = require( "./package.json" );
var _ = require( "lodash" );
var webpack = require( "webpack" );
var path = require( "path" );
const cleanWebpackPlugin = require( "clean-webpack-plugin" );
const TerserPlugin = require('terser-webpack-plugin');
var banner = [
" * <%= pkg.name %> - <%= pkg.description %>",
" * Author: <%= pkg.author %>",
" * Version: v<%= pkg.version %>",
" * Url: <%= pkg.homepage %>",
" * License(s): <%= pkg.license %>"
].join( "\n" );
var header = _.template( banner )( { pkg: pkg } );
let source = path.join( __dirname, "src", "lux.js" );
module.exports = {
mode: "production",
entry: {
"lux": source,
"lux.min": source
},
output: {
path: path.join( __dirname, "lib" ),
publicPath: "./js/",
library: "lux",
libraryTarget: "umd",
filename: "[name].js"
},
devtool: "source-map",
externals: [
{
postal: true,
machina: true,
lodash: {
root: "_",
commonjs: "lodash",
commonjs2: "lodash",
amd: "lodash"
},
react: {
root: "React",
commonjs: "react",
commonjs2: "react",
amd: "react"
}
}
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin( {
include: /\.min\.js$/,
extractComments: false
} )
]
},
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules|bower_components)/,
loader: "babel-loader",
query: {
compact: false,
presets: [
"es2015-without-strict",
"stage-0"
],
plugins: [ "add-module-exports" ]
}
}
]
},
plugins: [
new cleanWebpackPlugin( [ "lib" ], {
root: __dirname,
verbose: true,
dry: false
} ),
new webpack.BannerPlugin( header )
]
};