Skip to content

Commit e4050fe

Browse files
committed
deploying for production
1 parent f664788 commit e4050fe

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

source/guide/application.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,45 @@ describe('my-component', function () {
116116

117117
<p class="tip">Since Vue.js directives react to data updates asynchronously, when you are asserting DOM state after changing the data, you will have to do so in a `Vue.nextTick` callback.</p>
118118

119+
## Deploying for Production
120+
121+
The minified standalone build of Vue.js has already stripped out all the warnings for you for a smaller file size, but when you are using tools like Browserify for Webpack to build Vue.js applications, it's not so obvious how to do that.
122+
123+
Starting in 0.12.8, it is quite simple to configure the tools to strip out the warnings:
124+
125+
### Webpack
126+
127+
Use Webpack's [DefinePlugin](http://webpack.github.io/docs/list-of-plugins.html#defineplugin) to indicate a production environment, so that warning blocks can be automatically dropped by UglifyJS during minification. Example config:
128+
129+
``` js
130+
var webpack = require('webpack')
131+
132+
module.exports = {
133+
// ...
134+
plugins: [
135+
// ...
136+
new webpack.DefinePlugin({
137+
'process.env': {
138+
NODE_ENV: '"production"'
139+
}
140+
}),
141+
new webpack.optimize.UglifyJsPlugin({
142+
compress: {
143+
warnings: false
144+
}
145+
})
146+
]
147+
}
148+
```
149+
150+
### Browserify
151+
152+
Just run your bundling command with `NODE_ENV` set to `"production"`. Vue automatically applies [envify](https://github.com/hughsk/envify) transform to itself and makes warning blocks unreachable. For example:
153+
154+
``` bash
155+
NODE_ENV=production browserify -e main.js | uglifyjs -c -m > build.js
156+
```
157+
119158
## An Example
120159

121160
The [Vue.js Hackernews Clone](https://github.com/yyx990803/vue-hackernews) is an example application that uses Webpack + vue-loader for code organization, Director.js for routing, and HackerNews' official Firebase API as the backend. It's by no means a big application, but it demonstrates the combined usage of the concepts discussed on this page.

0 commit comments

Comments
 (0)