Skip to content

Commit

Permalink
perf: enable vue-loader template compilation caching
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 22, 2018
1 parent e5101b4 commit 8fe554c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
28 changes: 10 additions & 18 deletions packages/@vue/cli-service/lib/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = (api, options) => {
const resolveLocal = require('../util/resolveLocal')
const getAssetPath = require('../util/getAssetPath')
const inlineLimit = 10000
const useThreads = process.env.NODE_ENV === 'production' && options.parallel

webpackConfig
.context(api.service.context)
Expand Down Expand Up @@ -44,29 +43,22 @@ module.exports = (api, options) => {
// vue-loader --------------------------------------------------------------

const { genCacheConfig } = require('@vue/cli-shared-utils')
const vueLoaderCacheConfig = genCacheConfig(api, options, 'vue-loader')

const vueRule = webpackConfig.module
webpackConfig.module
.rule('vue')
.test(/\.vue$/)
.use('cache-loader')
.loader('cache-loader')
.options(genCacheConfig(api, options, 'vue-loader'))
.options(vueLoaderCacheConfig)
.end()

if (useThreads) {
vueRule
.use('thread-loader')
.loader('thread-loader')
}

vueRule
.use('vue-loader')
.loader('vue-loader')
.options({
compilerOptions: {
preserveWhitespace: false
}
})
.use('vue-loader')
.loader('vue-loader')
.options(Object.assign({
compilerOptions: {
preserveWhitespace: false
}
}, vueLoaderCacheConfig))

webpackConfig
.plugin('vue-loader')
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"thread-loader": "^1.1.5",
"uglifyjs-webpack-plugin": "^1.2.5",
"url-loader": "^1.0.1",
"vue-loader": "^15.1.0",
"vue-loader": "^15.2.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.8.2",
"webpack-chain": "^4.8.0",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10669,9 +10669,9 @@ vue-jest@^2.6.0:
tsconfig "^7.0.0"
vue-template-es2015-compiler "^1.6.0"

vue-loader@^15.1.0:
version "15.1.0"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-15.1.0.tgz#82a2a5c310951aba17ad5d8680fe016c77d37e80"
vue-loader@^15.2.0:
version "15.2.0"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-15.2.0.tgz#5a8138e490a1040942d2f10ae68fa72b5a923364"
dependencies:
"@vue/component-compiler-utils" "^1.2.1"
hash-sum "^1.0.2"
Expand Down

0 comments on commit 8fe554c

Please sign in to comment.