npm install --save-dev cache-loader
Add this loader in front of other (expensive) loaders to cache the result on disk.
Note that there is an overhead for saving the reading and saving the cache file, so only use this loader to cache expensive loaders.
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.js$/,
include: path.resolve("src"),
use: [
"cache-loader",
"babel-loader"
]
}
]
}
}
with options
use: [
{
loader: "cache-loader",
options: {
// provide a cache directory where cache items should be stored
cacheDirectory: path.resolve(".cache")
}
},
"babel-loader"
]
sokra |