Skip to content

Commit

Permalink
fix(svg-rule): reduce url-loader byte limit [#8]
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored Feb 11, 2019
1 parent 87247f3 commit 3b221fb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default async function module (moduleOptions) {
const options = {...DEFAULTS, ...moduleOptions, ...this.options.svgSprite}
const resolve = path => path.replace('~', this.nuxt.options.srcDir);

this.extendBuild(extendBuild.bind(this))

options._input = options.input
options.input = resolve(options.input);
options.output = resolve(options.output);
Expand Down Expand Up @@ -79,3 +81,18 @@ function setupHooks(options) {
}
})
}

function extendBuild(config) {
const urlLoader = config.module.rules.find(rule => String(rule.test).includes('svg'))
urlLoader.test = /\.(png|jpe?g|gif)$/

config.module.rules.push({
test: /\.svg$/,
use: [{
loader: 'url-loader',
options: {
limit: 12
},
}]
})
}

0 comments on commit 3b221fb

Please sign in to comment.