sass.rule.js 902 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  3. const getThemeVariable = require('./getThemeVariable');
  4. module.exports = function(options) {
  5. return {
  6. test: /\.scss$/,
  7. use: [
  8. MiniCssExtractPlugin.loader,
  9. {
  10. loader: 'css-loader',
  11. options: {
  12. importLoaders: 2,
  13. url: options.preserveUrl,
  14. sourceMap: options.sourceMap,
  15. minimize: options.minimize,
  16. },
  17. },
  18. {
  19. loader: 'postcss-loader',
  20. options: {
  21. sourceMap: options.sourceMap,
  22. config: { path: __dirname + '/postcss.config.js' },
  23. },
  24. },
  25. {
  26. loader: 'sass-loader',
  27. options: {
  28. sourceMap: options.sourceMap,
  29. functions: {
  30. 'getThemeVariable($themeVar, $themeName: dark)': getThemeVariable,
  31. },
  32. },
  33. },
  34. ],
  35. };
  36. };