-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
56 lines (54 loc) · 1.39 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
const path = require('path')
const webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
const absPath = dir => path.join(__dirname, dir)
const PKG = require('./package.json')
const DEV = process.env.NODE_ENV !== 'production'
module.exports = {
target: 'node',
devtool: 'source-map',
watch: DEV,
mode: DEV ? 'development' : 'production',
node: {
__dirname: false,
__filename: false,
},
entry: {
'index': absPath(`./src/index.js`),
},
resolve: {
modules: [
absPath('./src'),
'node_modules',
],
},
output: {
path: absPath(`./dist`),
filename: '[name].js',
libraryTarget: 'commonjs2',
pathinfo: true,
},
module: {
rules: [
{
test: /\.(jsx?)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: { cacheDirectory: './tmp/babel_cache/node' },
},
},
],
},
externals: [
nodeExternals(),
],
plugins: [
new webpack.DefinePlugin({
__DEV__: JSON.stringify(DEV),
__PRODUCTION__: JSON.stringify(!DEV),
__VERSION__: JSON.stringify(PKG.version),
}),
...DEV ? [ new webpack.NamedModulesPlugin() ] : [],
],
}