-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.js
29 lines (25 loc) · 1021 Bytes
/
index.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
module.exports = (api, projectOptions) => {
api.chainWebpack(webpackConfig => {
const pluginOptions = projectOptions.pluginOptions ? projectOptions.pluginOptions.svgSprite || {} : {};
const dir = api.resolve(pluginOptions.dir || 'src/assets/icons');
webpackConfig.module
.rule('svg-sprite')
.test(pluginOptions.test || /\.(svg)(\?.*)?$/)
.include
.add(dir)
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options(pluginOptions.loaderOptions || {
extract: true,
spriteFilename: projectOptions.filenameHashing ? 'img/icons.[hash:8].svg' : 'img/icons.svg',
});
webpackConfig
.plugin('svg-sprite')
.use(require('svg-sprite-loader/plugin'), [pluginOptions.pluginOptions || { plainSprite: true }]);
webpackConfig.module
.rule('svg')
.exclude
.add(dir);
});
};