|
| 1 | +const path = require('path'); |
| 2 | +const paths = require('../scripts/helpers/paths'); |
| 3 | +const CopyWebpackPlugin = require('copy-webpack-plugin'); |
| 4 | + |
| 5 | +module.exports = async ({ config, mode }) => { |
| 6 | + config.module.rules.push( |
| 7 | + { |
| 8 | + test: /\.scss$/, |
| 9 | + include: [ |
| 10 | + path.resolve(__dirname, '../ui'), |
| 11 | + path.resolve(__dirname, '../.storybook'), |
| 12 | + path.resolve(__dirname, '../shared'), |
| 13 | + path.resolve(__dirname, '../assets') |
| 14 | + ], |
| 15 | + use: [ |
| 16 | + { |
| 17 | + loader: path.resolve( |
| 18 | + __dirname, |
| 19 | + '../scripts/compile/lwc-style-loader.js' |
| 20 | + ) |
| 21 | + }, |
| 22 | + { |
| 23 | + loader: 'css-loader', |
| 24 | + options: { importLoaders: 2 } |
| 25 | + }, |
| 26 | + { |
| 27 | + loader: 'postcss-loader', |
| 28 | + options: { sourceMap: true } |
| 29 | + }, |
| 30 | + { |
| 31 | + loader: 'resolve-url-loader', |
| 32 | + options: { sourceMap: true } |
| 33 | + }, |
| 34 | + { |
| 35 | + loader: 'sass-loader', |
| 36 | + options: { sourceMap: true, outputStyle: 'compressed' } |
| 37 | + }, |
| 38 | + // Reads Sass vars from files or inlined in the options property |
| 39 | + // needed to reset the asset paths for webpack to load them, as we |
| 40 | + // assume we're loading from the assets folder with a relitive path |
| 41 | + // from the compile css monolith to the assets, like fonts |
| 42 | + { |
| 43 | + loader: '@epegzz/sass-vars-loader', |
| 44 | + options: { |
| 45 | + syntax: 'scss', |
| 46 | + files: [path.resolve(__dirname, './scss/framework/config.scss')] |
| 47 | + } |
| 48 | + } |
| 49 | + ] |
| 50 | + }, |
| 51 | + { |
| 52 | + test: /\.css$/, |
| 53 | + include: path.resolve(__dirname, '../ui'), |
| 54 | + use: ['raw-loader'] |
| 55 | + } |
| 56 | + ); |
| 57 | + config.plugins.push( |
| 58 | + new CopyWebpackPlugin([ |
| 59 | + { |
| 60 | + from: paths.icons, |
| 61 | + to: '/assets/icons' |
| 62 | + } |
| 63 | + ]) |
| 64 | + ); |
| 65 | + return config; |
| 66 | +}; |
0 commit comments