-
Notifications
You must be signed in to change notification settings - Fork 1
/
extra-webpack.config.js
56 lines (50 loc) · 1.98 KB
/
extra-webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const postcssModules = require('postcss-modules');
const path = require('path');
const AngularCompilerPlugin = require('@ngtools/webpack');
module.exports = (config, options) => {
/* SCSS EXTEND */
const scssRule = config.module.rules.find(x => x.test.toString().includes('scss'));
const postcssLoader = scssRule.use.find(x => x.loader.toString().includes('postcss-loader'));
const pluginFunc = postcssLoader.options.plugins;
const newPluginFunc = function () {
var plugs = pluginFunc.apply(this, arguments);
plugs.splice(plugs.length - 1, 0, postcssModules({ generateScopedName: "[hash:base64:5]" }));
return plugs;
}
postcssLoader.options.plugins = newPluginFunc;
/* HTML EXTEND */
config.module.rules.unshift(
{
test: /\.html$/,
use:(info) => {
return [
{ loader: 'raw-loader' },
{
loader: path.resolve('./scripts/loaders/html-css-modules.loader.js'),
options: {
file: info.resource
}
},
{
loader: 'posthtml-loader',
options: {
config: {
path: './',
ctx: {
include: { ...options },
content: { ...options }
}
},
}
},
]
}
},
);
const index = config.plugins.findIndex(p => p instanceof AngularCompilerPlugin.AngularCompilerPlugin);
const oldOptions = config.plugins[index]._options;
oldOptions.directTemplateLoading = false;
config.plugins.splice(index);
config.plugins.push(new AngularCompilerPlugin.AngularCompilerPlugin(oldOptions));
return config;
};