Skip to content

Commit c4a2719

Browse files
ulivzyyx990803
authored andcommitted
fix: fix unexpected error when options of cache-loader contains ! (#1334)
1 parent 2c8d245 commit c4a2719

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

docs/options.md

+4
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ Compiled the component for usage inside Shadow DOM. In this mode, the styles of
8181
- default: `undefined`
8282

8383
When both options are specified, enables file-system-based template compilation caching (requires `cache-loader` to be installed in the same project).
84+
85+
::: tip
86+
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 `!`.
87+
:::

docs/zh/options.md

+4
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ sidebar: auto
8181
- 默认值:`undefined`
8282

8383
当这两个选项同时被设置时,开启基于文件系统的模板编译缓存 (需要在工程里安装 `cache-loader`)。
84+
85+
::: tip 注意
86+
在内部,`vue-loader``cache-loader` 之间的交互使用了 [loader 的内联 import 语法](https://webpack.js.org/concepts/loaders/#inline)`!` 将会被认为是不同 loaders 之间的分隔符,所以请确保你的 `cacheDirectory` 路径中不包含 `!`
87+
:::

lib/loaders/pitcher.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const qs = require('querystring')
22
const loaderUtils = require('loader-utils')
3+
const hash = require('hash-sum')
34
const selfPath = require.resolve('../index')
45
const templateLoaderPath = require.resolve('./templateLoader')
56
const stylePostLoaderPath = require.resolve('./stylePostLoader')
@@ -74,7 +75,7 @@ module.exports.pitch = function (remainingRequest) {
7475
const cacheLoader = cacheDirectory && cacheIdentifier
7576
? [`cache-loader?${JSON.stringify({
7677
cacheDirectory,
77-
cacheIdentifier: cacheIdentifier + '-vue-loader-template'
78+
cacheIdentifier: hash(cacheIdentifier) + '-vue-loader-template'
7879
})}`]
7980
: []
8081
const request = genRequest([

0 commit comments

Comments
 (0)