forked from svgdotjs/svgdom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.cjs
49 lines (46 loc) · 1.44 KB
/
webpack.config.cjs
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
// webpack.config.js
const CircularDependencyPlugin = require('circular-dependency-plugin')
const fs = require('fs')
const path = require('path')
const nodeModules = {}
fs.readdirSync('node_modules')
.filter(function (x) {
return [ '.bin' ].indexOf(x) === -1
})
.forEach(function (mod) {
nodeModules[mod] = 'commonjs ' + mod
})
module.exports = {
mode: 'development',
entry: './main-module.js',
output: {
// library: 'svgdom',
libraryTarget: 'commonjs',
filename: './main-require.cjs',
path: __dirname
},
// This function is only to make __dirname work properly!!!
externals: [ nodeModules, function (context, request, callback) {
if (/dirname.cjs/.test(request)) {
return callback(null, 'commonjs ./' + path.join('./', path.relative(__dirname, context), request).replace(/\\/g, '/'))
}
callback()
} ],
devtool: 'inline-source-map',
plugins: [
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
exclude: /node_modules/,
// include specific files based on a RegExp
// include: /dir/,
// add errors to webpack instead of warnings
failOnError: true,
// allow import cycles that include an asyncronous import,
// e.g. via import(/* webpackMode: "weak" */ './file.js')
allowAsyncCycles: false,
// set the current working directory for displaying module paths
cwd: process.cwd()
})
],
target: 'node'
}