Skip to content

Commit 40c0526

Browse files
committed
Add disableCompress option
1 parent 0c36158 commit 40c0526

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed

bin/vue-build

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ program
3838
.option('-o, --open', 'Open browser')
3939
.option('--proxy [url]', 'Proxy API request')
4040
.option('--lib [libraryName]', 'Distribute component in UMD format')
41+
.option('--disable-compress', 'Disable compress when building in production mode')
4142
.parse(process.argv)
4243

4344
var args = program.args
@@ -75,7 +76,8 @@ var options = merge({
7576
proxy: program.proxy,
7677
production: program.production,
7778
lib: program.lib,
78-
watch: program.watch
79+
watch: program.watch,
80+
disableCompress: program.disableCompress
7981
})
8082

8183
function help () {
@@ -248,23 +250,37 @@ if (isYarn(__dirname)) {
248250
}
249251

250252
if (production) {
251-
webpackConfig.devtool = 'source-map'
252253
webpackConfig.plugins.push(
253254
new ProgressPlugin(),
254-
new webpack.optimize.UglifyJsPlugin({
255+
new webpack.LoaderOptionsPlugin({
256+
minimize: !options.disableCompress
257+
}),
258+
new ExtractTextPlugin(filenames.css)
259+
)
260+
261+
if (options.disableCompress) {
262+
webpackConfig.devtool = false
263+
} else {
264+
webpackConfig.devtool = 'source-map'
265+
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
255266
sourceMap: true,
256267
compressor: {
257-
warnings: false
268+
warnings: false,
269+
conditionals: true,
270+
unused: true,
271+
comparisons: true,
272+
sequences: true,
273+
dead_code: true,
274+
evaluate: true,
275+
if_return: true,
276+
join_vars: true,
277+
negate_iife: false
258278
},
259279
output: {
260280
comments: false
261281
}
262-
}),
263-
new webpack.LoaderOptionsPlugin({
264-
minimize: true
265-
}),
266-
new ExtractTextPlugin(filenames.css)
267-
)
282+
}))
283+
}
268284
} else {
269285
if (!options.watch) {
270286
webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin())

docs/build.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ Set custom filename for `js` `css` `static` files:
170170
}
171171
```
172172

173+
#### disableCompress
174+
175+
Type: `boolean`
176+
177+
In production mode, all generated files will be compressed and produce sourcemaps file. You can use `--disableCompress` to disable this behavior.
178+
173179
#### proxy
174180

175181
Type: `string`, `Object`

lib/run.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,15 @@ module.exports = function (webpackConfig, options) {
5858
}))
5959
console.log(`\n${chalk.bgGreen.black(' SUCCESS ')} Compiled successfully.\n`)
6060
if (!watch) {
61-
console.log(`The ${chalk.cyan(options.dist)} folder is ready to be deployed.`)
62-
console.log(`You may also serve it locally with a static server:\n`)
63-
console.log(` ${chalk.yellow('npm')} i -g serve`)
64-
console.log(` ${chalk.yellow('serve')} ${options.dist} --single\n`)
61+
if (options.lib) {
62+
console.log(`The ${chalk.cyan(options.dist)} folder is ready to be published.`)
63+
console.log(`Make sure you have correctly set ${chalk.cyan('package.json')}\n`)
64+
} else {
65+
console.log(`The ${chalk.cyan(options.dist)} folder is ready to be deployed.`)
66+
console.log(`You may also serve it locally with a static server:\n`)
67+
console.log(` ${chalk.yellow('npm')} i -g serve`)
68+
console.log(` ${chalk.yellow('serve')} ${options.dist}\n`)
69+
}
6570
}
6671
}
6772
}

0 commit comments

Comments
 (0)