This repository has been archived by the owner on Sep 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
76 lines (71 loc) · 2.27 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
/// <binding ProjectOpened='Run - Development, Run - Production' />
const path = require('path');
const webpack = require('webpack');
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
const bundleOutputDir = './dist';
const libDir = 'lib';
const srcDir = 'src';
const libraryName = 'ensure';
function DtsBundlePlugin() { }
DtsBundlePlugin.prototype.apply = function (compiler)
{
/*
compiler.plugin('done', function ()
{
var dts = require('dts-bundle');
dts.bundle({
name: libraryName,
main: `dts/index.d.ts`,
out: `.${bundleOutputDir}/index.d.ts`,
outputAsModuleFolder: true // to use npm in-package typings
});
});
*/
};
module.exports = () =>
{
const env = process.env.NODE_ENV.trim();
const isDevBuild = !(env && env === 'production');
return [{
mode: isDevBuild ? 'development' : 'production',
entry: { 'index': `./${libDir}/index.js` },
resolve: { extensions: ['.js'] },
devtool: 'source-map',
output: {
path: path.join(__dirname, bundleOutputDir),
filename: `[name].js`,
publicPath: 'dist/',
library: libraryName,
libraryTarget: 'umd'
},
externals: [
/^@michaelcoxon\/utilities.*$/
],
module: {
rules: [
{
test: /\.js$/,
include: /lib/,
}
]
},
plugins: [
new CheckerPlugin(),
...(isDevBuild
?
[
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[file].map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(bundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
]
:
[
// Plugins that apply in production builds only
new DtsBundlePlugin()
//new webpack.optimize.UglifyJsPlugin(),
])
]
}];
};