forked from jkbrzt/rrule
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
93 lines (87 loc) · 1.97 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
86
87
88
89
90
91
92
93
const webpack = require("webpack");
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const paths = {
demo: {
styles: path.resolve(__dirname, "demo/demo.css"),
template: path.resolve(__dirname, "demo/index.html")
},
demoDist: path.resolve(__dirname, "dist"),
es5: path.resolve(__dirname, "dist", "es5"),
esm: path.resolve(__dirname, "dist", "esm")
};
const commonConfig = {
output: {
filename: "[name].js",
path: paths.es5,
library: "rrule",
libraryTarget: "umd",
globalObject: "typeof self !== 'undefined' ? self : this"
},
devtool: "source-map",
mode: "production",
resolve: {
extensions: [".js"]
},
optimization: {
minimize: true,
minimizer: [
new UglifyJsPlugin({
include: /\.min\.js$/
})
]
}
};
const rruleConfig = Object.assign({
entry: {
rrule: path.join(paths.esm, "index.js"),
'rrule.min': path.join(paths.esm, "index.js")
},
externals: {
luxon: 'luxon'
},
}, commonConfig);
const rruleWithLuxonConfig = Object.assign({
entry: {
'rrule-tz': path.join(paths.esm, "index.js"),
'rrule-tz.min': path.join(paths.esm, "index.js")
},
}, commonConfig);
const demoConfig = {
entry: {
demo: "./demo/demo.coffee"
},
module: {
rules: [
{
exclude: /node_modules/,
loader: "coffee-loader",
test: /\.coffee$/
}
]
},
output: {
filename: "demo.js",
path: paths.demoDist
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new CopyWebpackPlugin([
{
from: paths.demo.styles,
to: paths.demoDist
}
]),
new HtmlWebpackPlugin({
template: paths.demo.template
})
],
devtool: "source-map",
mode: "production"
};
module.exports = [rruleConfig, rruleWithLuxonConfig, demoConfig];