-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextra-webpack.config.js
More file actions
55 lines (50 loc) · 2.04 KB
/
Copy pathextra-webpack.config.js
File metadata and controls
55 lines (50 loc) · 2.04 KB
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
const postcssModules = require('postcss-modules');
const path = require('path');
const AngularWebpackPlugin = require('@ngtools/webpack/src/ivy/plugin');
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.postcssOptions;
const newPluginFunc = function () {
var plugs = pluginFunc.apply(this, arguments);
plugs.plugins.splice(plugs.plugins.length - 1, 0, postcssModules({ generateScopedName: "[hash:base64:5]" }));
return plugs;
}
postcssLoader.options.postcssOptions = 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 => typeof p === 'object' && p.constructor.name === 'AngularWebpackPlugin');
const oldOptions = config.plugins[index].pluginOptions;
oldOptions.directTemplateLoading = false;
config.plugins.splice(index);
config.plugins.push(new AngularWebpackPlugin.AngularWebpackPlugin(oldOptions));
return config;
};