E
E
Evtera2021-05-07 16:49:41
JavaScript
Evtera, 2021-05-07 16:49:41

Why webpack 5 alias not working in html?

Hello. There is a webpack config. Here is a piece

entry: {
    _global: ["./js/_global/_global.js"],
    index: ["./js/index/#index.js"],
    about: ["./js/about/#about.js"],
  },
  output: {
    filename: "./js/[name].[contenthash].js",
    path: path.resolve(__dirname, "dist"),
  },
  resolve: {
    alias: {
      "@js": path.resolve(__dirname, "src/js"),
      "@scss": path.resolve(__dirname, "src/scss"),
      "@": path.resolve(__dirname, "src"),
      "@dist": path.resolve(__dirname, "."),
    },
  },


When you try to insert a picture, because of the nesting, you need to write such a path
<img src="../../assets/images/_global/icons/task__volume.png" alt="eqeqe" />


because [email protected] doesn't work.

<img src="[email protected]/assets/images/_global/icons/task__volume.png" alt="eqeqe" />


What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NarkoMan01, 2021-05-07
@NarkoMan01

If I'm not mistaken they don't work in html. They only work for js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question