D
D
Daniil Popov2021-03-29 15:03:12
webpack
Daniil Popov, 2021-03-29 15:03:12

How to fix the generated path for the included script?

There is a config

{
  mode: "development",
  entry: {
    "some-entry": {
      import: "./src/directory/some-entry",
      filename: "directory/some-entry/script/script.js"
    } 
  },
  output: {
    path: path.resolve(__dirname, "dist/"),
    filename: "script.js",
  },
  module: {},
  plugins: [
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, "./index.html"),
      filename: "directory/some-entry/index.html",
      inject: "body"
    })
  ]
}


Everything is assembled correctly. After building in directory/some-entry/index.html, the script is connected like this
<script defer src="../../directory/some-entry/script/script.js"></script></body>

but I would like it like this
<script defer src="./script/script.js"></script></body>

please tell me how to fix

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question