-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
85 lines (66 loc) · 1.82 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
// Import the Sourcemap plugin
const { SourceMapDevToolPlugin } = require('webpack');
// Import the Shebang plugin
const { ShebangPlugin } = require('./resources/webpack/shebang');
// Import the utilities
const { moduleFilename } = require('./resources/webpack/utils');
// Define the webpack build rules
module.exports = {
// Define the build environment
mode: 'production',
target: 'node',
devtool: 'eval',
// Define the modules to build and appropriate paths
entry: {
// Define the filesystem script to be used by the webpack resource
'resources/webpack/filesystem': `${__dirname}/src/filesystem.js`,
// Define the cli module for the package
'lib/cli': `${__dirname}/src/cli.js`
},
// Define the output rules
output: {
// Define the path to be the current root
path: __dirname,
// Define the file name including the path from the entry
filename: '[name].js',
// Setup the output as an umd module
libraryTarget: 'umd',
scriptType: 'module',
// Setup the sourcemap paths
// devtoolModuleFilenameTemplate: moduleFilename
devtoolModuleFilenameTemplate: '/[absolute-resource-path]'
},
// Add the pre source map loader
module: {
rules: [
{
test: /src[\//].*.js$/,
enforce: 'pre',
use: ['source-map-loader']
}
]
},
// Add the plugins
plugins: [
// Add the Shebang plugin
new ShebangPlugin(),
// Add the Sourcemap plugin
new SourceMapDevToolPlugin({
filename: '[name].js.map',
// columns: true,
// noSources: false,
// module: true,
exclude: /filesystem.js/
})
],
optimization: {
// providedExports: false,
mangleExports: false,
// concatenateModules: true,
usedExports: false,
},
stats: {
modules: false,
source: true,
}
};