svg-sprite-loader
svg-sprite-loader copied to clipboard
warning in ./src/assets/icons/home.svg Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Do you want to request a feature, report a bug or ask a question?
What is the current behavior?
What is the expected behavior?
If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code. The best way is to create repo with minimal setup to demonstrate a problem (package.json, webpack config and your code). It you don't want to create a repository - create a gist with multiple files
If this is a feature request, what is motivation or use case for changing the behavior?
Please tell us about your environment:
- Node.js version: ?
- webpack version: ?
- svg-sprite-loader version: ?
- OS type & version: ?
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
const path = require("path");
module.exports = {
publicPath: process.env.NODE_ENV === "production" ? "" : "/",
outputDir: process.env.NODE_ENV === "production" ? "dist" : "devDist",
lintOnSave: false,
// 配置svg
chainWebpack: (config) => {
config.module.rules.delete("svg");
config.module
.rule("svg-sprite-loader")
.test(/.svg$/)
.include.add(path.resolve("@/assets/icons"))
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: "icon-[name]",
});
},
css: {
loaderOptions: {
scss: {
prependData: @import "./src/styles/main.scss";,
},
},
},
};
top is my code,lastly i change code at here, before: .include.add(path.resolve("@/assets/icons")) change: .include.add(path.resolve("src/assets/icons")) hope can help you