loaders.js 683 B

1234567891011121314151617181920212223
  1. const { resolve } = require('./../utils');
  2. const env = require('../parseEnv');
  3. const cacheLoader = {
  4. loader: 'cache-loader',
  5. options: {
  6. // 提供一个存放缓存项的缓存目录
  7. cacheDirectory: resolve('node_modules/.cache/cache-loader'),
  8. },
  9. };
  10. // node-sass 中有个来自 Node.js 线程池的阻塞线程的 bug。 当使用 thread-loader 时,需要设置 workerParallelJobs:
  11. const threadLoader = (workerParallelJobs) => {
  12. const options = { workerParallelJobs };
  13. if (env.NODE_ENV === 'dev') {
  14. Object.assign(options, { poolTimeout: Infinity });
  15. }
  16. return { loader: 'thread-loader', options };
  17. };
  18. module.exports = {
  19. cacheLoader,
  20. threadLoader,
  21. };