-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
46 lines (41 loc) · 1.07 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
const webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
const isProductionMode = ~process.argv.indexOf('-p')
const outputDir = isProductionMode ? 'dist' : '.build'
const commandFiles = [''].map( command => {
return `wcal${command}`;
})
const commonOptions = {
resolve: {
extensions: ['', '.js', '.sass'],
modulesDirectories: ['src', 'node_modules']
}
}
const binConfigs = commandFiles.map(commandFile => {
return Object.assign({}, commonOptions, {
entry: `./src/bin/${commandFile}.js`,
target: 'node',
node: {
__dirname: false,
__filename: false,
},
module: {
preLoaders: [{
test: /\.js$/, loader: "eslint-loader", exclude: /node_modules/
}],
loaders: [{
loader: 'babel',
test: /\.js?$/,
exclude: /node_modules/
}]
},
plugins: [
new webpack.BannerPlugin('#!/usr/bin/env node', { raw: true })
],
output: {
filename: `${outputDir}/bin/${commandFile}`
},
externals: [ nodeExternals() ]
})
})
module.exports = binConfigs