Skip to content

Commit

Permalink
fix: fix unexpected error when options of cache-loader contains ! (#1334
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ulivz authored and yyx990803 committed Jun 1, 2018
1 parent 2c8d245 commit c4a2719
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ Compiled the component for usage inside Shadow DOM. In this mode, the styles of
- default: `undefined`

When both options are specified, enables file-system-based template compilation caching (requires `cache-loader` to be installed in the same project).

::: tip
Interaction between `vue-loader` and `cache-loader` uses [inline loader import syntax](https://webpack.js.org/concepts/loaders/#inline) under the hook, the `!` will be treated as the separator between different loaders, so please ensure `cacheDirectory` doesn't contain `!`.
:::
4 changes: 4 additions & 0 deletions docs/zh/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ sidebar: auto
- 默认值:`undefined`

当这两个选项同时被设置时,开启基于文件系统的模板编译缓存 (需要在工程里安装 `cache-loader`)。

::: tip 注意
在内部,`vue-loader``cache-loader` 之间的交互使用了 [loader 的内联 import 语法](https://webpack.js.org/concepts/loaders/#inline)`!` 将会被认为是不同 loaders 之间的分隔符,所以请确保你的 `cacheDirectory` 路径中不包含 `!`
:::
3 changes: 2 additions & 1 deletion lib/loaders/pitcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const qs = require('querystring')
const loaderUtils = require('loader-utils')
const hash = require('hash-sum')
const selfPath = require.resolve('../index')
const templateLoaderPath = require.resolve('./templateLoader')
const stylePostLoaderPath = require.resolve('./stylePostLoader')
Expand Down Expand Up @@ -74,7 +75,7 @@ module.exports.pitch = function (remainingRequest) {
const cacheLoader = cacheDirectory && cacheIdentifier
? [`cache-loader?${JSON.stringify({
cacheDirectory,
cacheIdentifier: cacheIdentifier + '-vue-loader-template'
cacheIdentifier: hash(cacheIdentifier) + '-vue-loader-template'
})}`]
: []
const request = genRequest([
Expand Down

0 comments on commit c4a2719

Please sign in to comment.