提交 9e6708d1 编写于 作者: J JJ Kasper 提交者: Joe Haddad

Set custom cacheIdentifier for babel-loader (#6982)

* Set custom cacheIdentifier for babel-
loader that we can increment

* Update to consider external babel config
for cacheIdentifier

* Update to follow babel loader's cacheIdentifier behavior
上级 54e94547
import babelLoader from 'babel-loader'
import hash from 'string-hash'
import { basename } from 'path'
import { join, basename } from 'path'
import babelLoader from 'babel-loader'
// increment 'a' to invalidate cache
const cacheKey = 'babel-cache-' + 'a' + '-'
module.exports = babelLoader.custom(babel => {
const presetItem = babel.createConfigItem(require('../../babel/preset'), { type: 'preset' })
......@@ -14,12 +17,20 @@ module.exports = babelLoader.custom(babel => {
const custom = {
isServer: opts.isServer
}
const filename = join(opts.cwd, 'noop.js')
const loader = Object.assign({
cacheCompression: false,
cacheDirectory: true
cacheDirectory: true,
cacheIdentifier: cacheKey + JSON.stringify(
babel.loadPartialConfig({
filename,
cwd: opts.cwd,
sourceFileName: filename
}).options
)
}, opts)
delete loader.isServer
delete loader.isServer
return { loader, custom }
},
config (cfg, { source, customOptions: { isServer } }) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册