igroot-builder
Version:
白山——zeus系统前端打包工具
37 lines (32 loc) • 1.1 kB
JavaScript
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const {options: {buildPath, esModule}} = require('../bsy')
try {var {dependencies = {}} = require(path.resolve('package.json'))}
catch (e) {
console.error(chalk.red('Can not find the \'package.json\'!'))
console.warn(chalk.yellow('Please check the directory path.\n'))
throw new Error('Can not find the \'package.json\'!')
}
const vendors = new Set(Object.keys(dependencies))
// esModule 内的模块需要主配置中的 loader 处理
esModule.forEach(module => vendors.delete(module))
module.exports = {
mode: 'production',
//需要指定target (js兼容web和node) 用以修复chunkLoading is not implement的bug
target:"web",
entry: {vendors: Array.from(vendors)},
output: {
filename: '[name].dll.js',
path: path.resolve(buildPath),
library: '[name]'
},
resolve: {extensions: ['.js', '.jsx', '.json']},
plugins: [
new webpack.DllPlugin({
name: '[name]',
path: path.resolve(buildPath, 'manifest.json')
})
],
performance: {hints: false}
}