Created
May 6, 2017 05:56
-
-
Save YasushiKobayashi/618e94e224d9aa57e14bed959b73369f to your computer and use it in GitHub Desktop.
ディレクトリ構成を維持しつつwebpackで複数ファイルをビルドする(nodejs用)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webpack from 'webpack'; | |
import path from 'path'; | |
import glob from 'glob'; | |
import nodeExternals from 'webpack-node-externals'; | |
import loaders from './webpack.loaders'; | |
const jsBasePath = path.resolve(__dirname, './'); | |
const targetDirectories = ['es']; | |
const targets = glob.sync(`${jsBasePath}/+(${targetDirectories.join('|')})/*.js`); | |
const entries = {}; | |
targets.forEach((value) => { | |
const re = new RegExp(`${jsBasePath}/`); | |
const key = value.replace(re, ''); | |
entries[key] = value; | |
}); | |
module.exports = { | |
entry: entries, | |
output: { | |
path: path.join(__dirname, 'js'), | |
filename: '[name]', | |
}, | |
module: { | |
loaders, | |
}, | |
target: 'node', | |
node: { | |
__filename: true, | |
__dirname: true, | |
}, | |
externals: nodeExternals(), | |
plugins: [ | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
warnings: false, | |
drop_console: true, | |
drop_debugger: true, | |
}, | |
}), | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment