forked from jkbrzt/rrule
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
113 lines (107 loc) · 2.41 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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: {
source: path.resolve(__dirname, 'demo'),
styles: path.resolve(__dirname, "demo", "demo.css"),
template: path.resolve(__dirname, "demo", "index.html")
},
source: path.resolve(__dirname, 'src'),
demoDist: path.resolve(__dirname, "dist", "esm", "demo"),
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', '.ts']
},
module: {
rules: [
{
exclude: /node_modules/,
loader: "ts-loader",
test: /\.ts$/
}
]
},
optimization: {
minimize: true,
minimizer: [
new UglifyJsPlugin({
exclude: /\.ts$/,
include: /\.min\.js$/
})
]
}
};
const rruleConfig = Object.assign({
entry: {
rrule: path.join(paths.source, "index.ts"),
'rrule.min': path.join(paths.source, "index.ts")
},
externals: {
luxon: 'luxon'
},
}, commonConfig);
const rruleWithLuxonConfig = Object.assign({
entry: {
'rrule-tz': path.join(paths.source, "index.ts"),
'rrule-tz.min': path.join(paths.source, "index.ts")
},
}, commonConfig);
const demoConfig = {
entry: {
demo: path.join(paths.demo.source, "demo.ts"),
},
module: {
rules: [
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
},
{
exclude: /node_modules/,
loader: "ts-loader",
test: /\.ts$/
}
]
},
output: {
filename: "demo.js",
path: paths.demoDist
},
resolve: {
extensions: [".js", ".ts"]
},
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];