Skip to content

DEPRECATED. Adds persistent on-disk caching to webpack loaders

Notifications You must be signed in to change notification settings

jsdf/cached-loader

Repository files navigation

cached-loader

Adds persistent on-disk caching to webpack loaders

deprecated. use webpack-contrib/cache-loader instead.

Example

var path = require('path');
var combineLoaders = require('webpack-combine-loaders');

// some external config
var sassConfig = require('./sassConfig');

// some environmental config
var opts = {
  rootDir: process.cwd(),
  cssSourcemaps: Boolean(process.env.NODE_ENV !== 'production'),
};

module.exports = {
  module: {
    loaders: [
     {
        test: /\.scss$/,
        loader: combineLoaders([
          {
            loader: 'cached-loader',
            query: {
              cacheDirectory: path.join(opts.rootDir, 'tmp/cache/cached-loader'),
              cacheIdentifier: JSON.stringify(opts) + JSON.stringify(sassConfig),
            },
          },
          {
            loader: 'style-loader',
          },
          {
            loader: 'css-loader',
            query: {
              sourceMap: opts.cssSourcemaps,
            },
          },
          {
            loader: 'postcss-loader',
          },
          {
            loader: 'sass-loader',
            query: Object.assign({}, sassConfig, {
              sourceMap: opts.cssSourcemaps,
            }),
          },
        ]),
      },
    ],
  },
};

Now webpack should be faster from a cold start.

See also

About

DEPRECATED. Adds persistent on-disk caching to webpack loaders

Resources

Stars

Watchers

Forks

Packages

No packages published