Sha256: 640d34aaa72de6d38bbf3283c710ad9ac5bcdd6f3accf42aa0bf5c2d24f9bf0b
Contents?: true
Size: 1.51 KB
Versions: 12
Compression:
Stored size: 1.51 KB
Contents
const path = require("path"); const miniCssExtractPlugin = require("mini-css-extract-plugin"); const { inliningCss } = require("@rails/webpacker"); const overrideSassRule = (modifyConfig) => { const sassLoaderPath = path.resolve(__dirname, "loaders/decidim-sass-loader") // eslint-disable-line no-undef const sassRule = modifyConfig.module.rules.find( (rule) => rule.test.toString() === "/\\.(scss|sass)(\\.erb)?$/i" ); if (sassRule) { const existingLoader = sassRule.use.find((use) => { return (typeof use === "object") && use.loader.match(/sass-loader/); }); if (existingLoader) { existingLoader.loader = sassLoaderPath; } else { sassRule.use.push({ loader: sassLoaderPath }); } } else { // Add the sass rule let baseLoader = "style-loader"; if (!inliningCss) { baseLoader = miniCssExtractPlugin.loader; } modifyConfig.module.rules.push({ test: /\.(scss|sass)(\.erb)?$/i, use: [ baseLoader, { loader: require.resolve("css-loader"), options: { sourceMap: true, importLoaders: 2 } }, { loader: "postcss-loader", options: { sourceMap: true } }, { loader: sassLoaderPath } ] }) } return modifyConfig; } // Since all modifiers are functions, we can use a reduce clause to apply all them module.exports = (originalConfig) => [overrideSassRule].reduce((acc, modifier) => modifier(acc), originalConfig)
Version data entries
12 entries across 12 versions & 1 rubygems