|
| 1 | +const fs = require('fs'); |
1 | 2 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
2 | 3 |
|
| 4 | +const bootstrapPath = __dirname + '/node_modules/bootstrap-sass/assets/stylesheets'; |
| 5 | + |
| 6 | +// A custom node-sass importer that removes some unwanted rules from _normalize.scss. |
| 7 | +function importerWhichRewritesBootstrapNormalizeScss(url, prev, done) { |
| 8 | + if (url != 'bootstrap/normalize') { |
| 9 | + done(null); |
| 10 | + return; |
| 11 | + } |
| 12 | + |
| 13 | + fs.readFile(bootstrapPath + '/bootstrap/_normalize.scss', 'utf8', (err, data) => { |
| 14 | + if (err) return done(err); |
| 15 | + |
| 16 | + function remove(what) { |
| 17 | + if (!data.includes(what)) throw Error(`"${what}" not found`); |
| 18 | + data = data.replace(what, ''); |
| 19 | + } |
| 20 | + |
| 21 | + // Don't use pointer cursor on buttons. |
| 22 | + // http://lists.w3.org/Archives/Public/public-css-testsuite/2010Jul/0024.html |
| 23 | + remove('cursor: pointer; // 3'); |
| 24 | + |
| 25 | + // Don't inherit color and font on inputs and selects. |
| 26 | + remove('color: inherit; // 1'); |
| 27 | + remove('font: inherit; // 2'); |
| 28 | + |
| 29 | + done({ contents: data }); |
| 30 | + }); |
| 31 | +} |
| 32 | + |
3 | 33 | const outputPath = __dirname + '/votrfront/static'; |
4 | 34 |
|
5 | 35 | module.exports = function (env, args) { |
@@ -43,8 +73,9 @@ module.exports = function (env, args) { |
43 | 73 | { |
44 | 74 | loader: 'sass-loader', |
45 | 75 | options: { |
46 | | - includePaths: [__dirname + '/node_modules/bootstrap-sass/assets/stylesheets'], |
| 76 | + includePaths: [bootstrapPath], |
47 | 77 | outputStyle: mode == 'development' ? undefined : 'compressed', |
| 78 | + importer: importerWhichRewritesBootstrapNormalizeScss, |
48 | 79 | }, |
49 | 80 | }, |
50 | 81 | ], |
|
0 commit comments