Skip to content
This repository has been archived by the owner on Dec 12, 2017. It is now read-only.

Commit

Permalink
Merge pull request #21 from ElemeFE/fix/module-name
Browse files Browse the repository at this point in the history
update option
  • Loading branch information
QingWei-Li committed May 3, 2016
2 parents 7e51b2d + 5210a40 commit 29c7e4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ cooking.set({
urlLoaderLimit: 10000,
// 接受 amd cjs umd var,其中 cjs 会被翻译成 webpack 的 commonjs2
format: 'var',
// 如果format 为 'umd',需要设置该值
umdName: '',
// 如果format 为 'umd' 或 'amd',需要设置该值
moduleName: '',

// 会加载 CommonsChunkPlugin,接受 String|Object
// 如果有多个可以配制成 Object, {'name': 'filename'}
Expand Down
2 changes: 1 addition & 1 deletion test/cooking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test('cooking set format', t => {

cooking.set({
format: 'umd',
umdName: 'ABC'
moduleName: 'ABC'
})

t.is(cooking.config.output.library, 'ABC')
Expand Down
12 changes: 8 additions & 4 deletions util/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ module.exports = function (userConfig, baseConfig) {
config.output.libraryTarget = userConfig.format
}

// umdName
if (userConfig.format === 'umd' && !userConfig.umdName) {
logger.fatal('请配置 umdName')
// moduleName
if (userConfig.format === 'umd' || userConfig.format === 'amd') {
if (userConfig.moduleName) {
config.output.library = userConfig.moduleName
config.output.umdNamedDefine = true
} else {
logger.fatal('请配置 moduleName')
}
}
config.output.library = userConfig.umdName

// plugin
config.plugins.Define = new webpack.DefinePlugin({
Expand Down

0 comments on commit 29c7e4b

Please sign in to comment.