-
Notifications
You must be signed in to change notification settings - Fork 24
/
webpack.config.js
75 lines (73 loc) · 2.16 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
'use strict';
var webpack = require('webpack');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var WebpackCopyAfterBuildPlugin = require('webpack-copy-after-build-plugin');
var path = require('path');
var libraryName = 'RusCryptoJS';
var filename = 'ruscrypto.min.js';
module.exports = (env, argv) => {
if (argv.mode === 'production') {
var plugins = [
new CleanWebpackPlugin([
'./dist'
]),
new WebpackCopyAfterBuildPlugin({
main: '../docs/js/' + filename
})
];
var devServer = undefined;
}
else {
var plugins = [
new webpack.HotModuleReplacementPlugin()
];
var devServer = {
hot: true,
publicPath: "/js/",
contentBase: "./docs",
};
}
return {
entry: {
main: [ './src' ]
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: filename,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
// https://github.com/webpack/webpack/issues/1625#issuecomment-407553490
globalObject: "typeof self !== 'undefined' ? self : this"
},
resolve: {
extensions: ['.js'],
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
["@babel/preset-env", {
debug: false,
useBuiltIns: "usage",
targets: {
chrome: "60",
firefox: "52",
ie: "11",
safari: "10"
}
}]
]
}
}
}],
},
plugins: plugins,
devtool: "source-map",
devServer: devServer
}
};