ã¬ã¤ã
åºæ¬çãªä½¿ãæ¹
- ã¤ã³ã¹ãã¼ã«
- ã¯ããã«
- Vue ã¤ã³ã¹ã¿ã³ã¹
- ãã³ãã¬ã¼ãæ§æ
- ç®åºããããã£ã¨ã¦ã©ããã£
- ã¯ã©ã¹ã¨ã¹ã¿ã¤ã«ã®ãã¤ã³ãã£ã³ã°
- æ¡ä»¶ä»ãã¬ã³ããªã³ã°
- ãªã¹ãã¬ã³ããªã³ã°
- ã¤ãã³ããã³ããªã³ã°
- ãã©ã¼ã å ¥åãã¤ã³ãã£ã³ã°
- ã³ã³ãã¼ãã³ãã®åºæ¬
ã³ã³ãã¼ãã³ãã®è©³ç´°
- ã³ã³ãã¼ãã³ãã®ç»é²
- ããããã£
- ã«ã¹ã¿ã ã¤ãã³ã
- ã¹ããã
- åç & éåæã³ã³ãã¼ãã³ã
- ç¹å¥ãªåé¡ã«å¯¾å¦ãã
ãã©ã³ã¸ã·ã§ã³ã¨ã¢ãã¡ã¼ã·ã§ã³
- Enter/Leave ã¨ãã©ã³ã¸ã·ã§ã³ä¸è¦§
- ç¶æ ã®ãã©ã³ã¸ã·ã§ã³
åå©ç¨ã¨æ§æ
- ããã¯ã¹ã¤ã³
- ã«ã¹ã¿ã ãã£ã¬ã¯ãã£ã
- æç»é¢æ°ã¨JSX
- ãã©ã°ã¤ã³
- ãã£ã«ã¿ã¼
ãã¼ã«
- åä¸ãã¡ã¤ã«ã³ã³ãã¼ãã³ã
- ãã¹ã
- TypeScript ã®ãµãã¼ã
- ãããã¯ã·ã§ã³ç°å¢ã¸ã®é ä¿¡
ã¹ã±ã¼ã«ã¢ãã
- ã«ã¼ãã£ã³ã°
- ç¶æ 管ç
- ãµã¼ããµã¤ãã¬ã³ããªã³ã°
- ã»ãã¥ãªãã£
å é¨
- ãªã¢ã¯ãã£ãã®æ¢æ±
移è¡
- Vue 1.x ããã®ç§»è¡
- Vue Router 0.7.x ããã®ç§»è¡
- Vuex 0.6.x ãã 1.0 ã¸ã®ç§»è¡
ãã®ä»
- ä»ã®ãã¬ã¼ã ã¯ã¼ã¯ã¨ã®æ¯è¼
- Vue.js ã³ãã¥ããã£ã¸åå ãã¾ããã!
- ãã¼ã ã«ä¼ãã
v2.x 以åã®ããã¥ã¡ã³ãã§ãã v3.x ã®ããã¥ã¡ã³ããè¦ããå ´åã¯ãã¡ã
ãããã¯ã·ã§ã³ç°å¢ã¸ã®é ä¿¡
æçµæ´æ°æ¥: 2018å¹´12æ22æ¥
以éã®ãã³ãã®ã»ã¨ãã©ã¯ãVue CLI ã使ã£ã¦ããã°ããã©ã«ãã§æå¹ã«ãªãã¾ãããã®ã»ã¯ã·ã§ã³ã¯ãããªããç¬èªã®ãã«ãã»ããã¢ããã使ã£ã¦ããå ´åã®ã¿é¢ä¿ãããã¾ãã
ãããã¯ã·ã§ã³ã¢ã¼ããæå¹ã«ãã
éçºä¸ãVue ã¯ä¸è¬çãªã¨ã©ã¼ãè½ã¨ãç©´ã«å½¹ç«ã¤å¤ãã®è¦åã表示ãã¾ãããããããããã®è¦åæååã¯ããããã¯ã·ã§ã³ç°å¢ã§ã¯å½¹ã«ç«ããªããªããã¢ããªã±ã¼ã·ã§ã³ã®ãã¤ãã¼ããµã¤ãºã大ãããªãã¾ããããã«ããããã®è¦åãã§ãã¯ã®ä¸ã«ã¯ãéç¨ã¢ã¼ãã§åé¿ã§ããã©ã³ã¿ã¤ã ã³ã¹ããå°ãããã®ãããã¾ãã
ãã«ããã¼ã«ãªã
å®å
¨ãã«ãã使ç¨ãã¦ããå ´åãã¤ã¾ããã«ããã¼ã«ãªãã§ç´æ¥ã¹ã¯ãªããã¿ã°ã使ç¨ã㦠Vue ãçµã¿è¾¼ãå ´åã¯ã縮å°ãã¼ã¸ã§ã³ (vue.min.js
) ããããã¯ã·ã§ã³ç¨ã«ä½¿ç¨ãã¦ãã ããã ãããã®ãã¼ã¸ã§ã³ãã¤ã³ã¹ãã¼ã«ã¬ã¤ãä¸ã«ããã¾ãã
ãã«ããã¼ã«ãã
Webpack ã Browserify ã®ãããªãã«ããã¼ã«ã使ç¨ããå ´åããããã¯ã·ã§ã³ã¢ã¼ã㯠Vue ã®ã½ã¼ã¹ã³ã¼ãå
ã® process.env.NODE_ENV
ã«ãã£ã¦æ±ºå®ãããããã©ã«ãã§éçºã¢ã¼ãã«ãªãã¾ããã©ã¡ãã®ãã«ããã¼ã«ãããã®å¤æ°ãä¸æ¸ãã㦠Vue ã®ãããã¯ã·ã§ã³ã¢ã¼ããæå¹ã«ããæ¹æ³ãæä¾ãã¾ãããã«ãä¸ã«è¦åã縮å°ãã¼ã« (minifier) ã«ãã£ã¦åãé¤ããã¾ããå
¨ã¦ã® vue-cli
ãã³ãã¬ã¼ãã«ã¯ããªãã®ããã«ãããããè¨å®ããããã³ãã¬ã¼ããããã¾ããããããã©ã®ããã«è¡ãããããç¥ããã¨ã¯æçã§ããã:
Webpack
Webpack 4 以éã§ã¯ãmode
ãªãã·ã§ã³ã使ç¨ã§ãã¾ã:
module.exports = {
mode: 'production'
}
ããããWebpack 3 以åã§ã¯ãDefinePlugin ã使ç¨ããå¿ è¦ãããã¾ã:
var webpack = require('webpack')
module.exports = {
// ...
plugins: [
// ...
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
]
}
Browserify
"production"
ã«è¨å®ããNODE_ENV
ç°å¢å¤æ°ã使ã£ã¦ãã³ããªã³ã°ã³ãã³ããå®è¡ãã¦ãã ãããããã¯vueify
ã«ããããªãã¼ãã¨éçºé¢é£ã®ã³ã¼ããå«ã¾ãªãããã«æ示ãã¾ãã- ããªãã®ãã³ãã«ã« envify ã°ãã¼ãã«å¤æãé©ç¨ãã¦ãã ããã ãã㯠minifier 㧠Vue ã½ã¼ã¹ã³ã¼ãå ã§ç°å¢å¤æ°ã®æ¡ä»¶ä¸ã§å²ãããç®æå ¨ã¦ãåãé¤ããã¨ã許å¯ãã¾ãã
NODE_ENV=production browserify -g envify -e main.js | uglifyjs -c -m > build.js
ãããã¯ãenvifyã Gulp ã¨ã¨ãã«ä½¿ãã¾ã:
// ç°å¢å¤æ°ãæå®ããããã« envify ã®ã«ã¹ã¿ã ã¢ã¸ã¥ã¼ã«ã使ãã¾ã var envify = require('envify/custom') browserify(browserifyOptions) .transform(vueify) .transform( // node_modules ãã¡ã¤ã«ãå¦çããããã«å¿ è¦ã§ã { global: true }, envify({ NODE_ENV: 'production' }) ) .bundle()
ãããã¯ãenvify ã Grunt 㨠grunt-browserify ã¨ã¨ãã«ä½¿ãã¾ã:
// ç°å¢å¤æ°ãæå®ããããã« envify ã®ã«ã¹ã¿ã ã¢ã¸ã¥ã¼ã«ã使ãã¾ã var envify = require('envify/custom') browserify: { dist: { options: { // grunt-browserify ã®ããã©ã«ãã®é çªããé¸è±ããããã®é¢æ° configure: b => b .transform('vueify') .transform( // node_modules ãã¡ã¤ã«ãå¦çããããã«å¿ è¦ã§ã { global: true }, envify({ NODE_ENV: 'production' }) ) .bundle() } } }
Rollup
@rollup/plugin-replace ã使ç¨ãã¾ã:
const replace = require('@rollup/plugin-replace')
rollup({
// ...
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify( 'production' )
})
]
}).then(...)
ãã³ãã¬ã¼ãã®ããªã³ã³ãã¤ã«
DOM å ã®ãã³ãã¬ã¼ãã¾ã㯠JavaScript å ã®ãã³ãã¬ã¼ãæååã使ç¨ããå ´åããã³ãã¬ã¼ãããæç»é¢æ°ã¸ã®ã³ã³ãã¤ã«ã¯ãã®å ´ (on the fly) ã§å®è¡ããã¾ããé常ãã»ã¨ãã©ã®å ´åãããã¯ååé«éã§ãããã¢ããªã±ã¼ã·ã§ã³ã®ããã©ã¼ãã³ã¹ãéè¦ãªå ´åã¯é¿ããã®ãæåã§ãã
ãã³ãã¬ã¼ããããªã³ã³ãã¤ã«ããæãç°¡åãªæ¹æ³ã¯ãåä¸ãã¡ã¤ã«ã³ã³ãã¼ãã³ãã使ç¨ãããã¨ã§ããé¢é£ãããã«ãã®ã»ããã¢ããã¯èªåçã«ããªã³ã³ãã¤ã«ãå®è¡ããããããã«ããããã³ã¼ãã«ã¯çã®ãã³ãã¬ã¼ãæååã§ã¯ãªããã§ã«ã³ã³ãã¤ã«ãããæç»é¢æ°ãå«ã¾ãã¦ãã¾ãã
Webpack ã使ç¨ãã¦ããå ´åãJavaScript 㨠ãã³ãã¬ã¼ãã®åé¢ã好ããªãããã«ãã¹ãããä¸ã«ãã³ãã¬ã¼ããã¡ã¤ã«ã JavaScript æç»é¢æ°ã«å¤æãã vue-template-loader ã使ç¨ãããã¨ãã§ãã¾ãã
ã³ã³ãã¼ãã³ã CSS ã®æ½åº
åä¸ãã¡ã¤ã«ã³ã³ãã¼ãã³ãã使ç¨ããå ´åãã³ã³ãã¼ãã³ãå
ã® CSS 㯠JavaScript ãä»ã㦠<style>
ã¿ã°ã¨ãã¦åçã«æ¿å
¥ããã¾ããããã¯å®è¡æã®ã³ã¹ããä½ãããµã¼ãã¼å´ã®ã¬ã³ããªã³ã°ã使ç¨ãã¦ããå ´åã¯ãâã¹ã¿ã¤ã«ã®ãªãã³ã³ãã³ãã®ãã©ãã·ã¥âãçºçãã¾ãããã¹ã¦ã®ã³ã³ãã¼ãã³ãã«ããã£ã¦ CSS ãåããã¡ã¤ã«ã«æ½åºãããããã®åé¡ãåé¿ããã«ã¯ãããè¯ã CSS ã®ç¸®å°å (minification) ã¨ãã£ãã·ã³ã°ãããã®ãããè¯ãã§ãã
ããããã®ãã«ããã¼ã«ã®ããã¥ã¡ã³ããåç §ãã¦ãã ãã:
- Webpack + vue-loader (
vue-cli
ã® webpack ãã³ãã¬ã¼ãã¯æ¢ã«è¨å®æ¸ã¿) - Browserify + vueify
- Rollup + rollup-plugin-vue
ã©ã³ã¿ã¤ã ã¨ã©ã¼ã®è¿½è·¡
ã³ã³ãã¼ãã³ãã®æç»ä¸ã«ã¨ã©ã¼ãçºçããå ´åãã°ãã¼ãã«ãª Vue.config.errorHandler
é¢æ°ã«è¨å®ãããé¢æ°ã«ããã渡ããã¾ãããã®ããã¯ã Vue åãã«å
¬å¼ã«çµ±åããã Sentry ã®ãããªã¨ã©ã¼è¿½è·¡ãµã¼ãã¹ã¨å
±ã«ä½¿ç¨ãããã¨ã¯è¯ãã¢ã¤ãã¢ã§ãã