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 #76 from ElemeFE/fix/clear
Browse files Browse the repository at this point in the history
cooking: fix clear in development
  • Loading branch information
QingWei-Li committed Sep 11, 2016
2 parents 071ba07 + 9987c4e commit 21ab95c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions packages/cooking/util/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ module.exports = function (userConfig, baseConfig) {
// extractCSS
if (userConfig.devServer) {
extractCSS(userConfig.devServer.extractCSS, config, false)

// clean
if (is.Boolean(userConfig.devServer.clean)) {
config.__COOKING_CLEAN__ = userConfig.devServer.clean
} else {
config.__COOKING_CLEAN__ = true
}
}

// devtool
Expand Down Expand Up @@ -158,6 +165,13 @@ module.exports = function (userConfig, baseConfig) {
}
}

// clean
if (is.Boolean(userConfig.clean)) {
config.__COOKING_CLEAN__ = userConfig.clean
} else {
config.__COOKING_CLEAN__ = true
}

extractCSS(userConfig.extractCSS, config, userConfig.hash)
}

Expand All @@ -176,13 +190,6 @@ module.exports = function (userConfig, baseConfig) {
config.postcss = require('./load-postcss')(userConfig.postcss)
}

// clean
if (is.Boolean(userConfig.clean)) {
config.__COOKING_CLEAN__ = userConfig.clean
} else {
config.__COOKING_CLEAN__ = true
}

// chunk
const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin
const chunks = userConfig.chunk
Expand Down
2 changes: 1 addition & 1 deletion packages/cooking/util/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = function (config) {
process.env.NODE_ENV === 'development' ? config.devServer : false
)

if (config.__COOKING_CLEAN__ && process.env.NODE_ENV === 'production') {
if (config.__COOKING_CLEAN__) {
shelljs.rm('-rf', config.output.path)
}

Expand Down
1 change: 1 addition & 0 deletions test/cooking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ test('cooking set extractCSS in development', t => {
})

test('cooking clean', t => {
process.env.NODE_ENV = 'production'
cooking.set({
clean: true
})
Expand Down

0 comments on commit 21ab95c

Please sign in to comment.