Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #478

Open
huawuhe opened this issue Nov 26, 2021 · 2 comments

Comments

@huawuhe
Copy link

huawuhe commented Nov 26, 2021

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)

@huawuhe
Copy link
Author

huawuhe commented Nov 26, 2021

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";,
},
},
},
};

@huawuhe
Copy link
Author

huawuhe commented Nov 26, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant