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

Support publicPath: "auto" #350

Closed
caseyjhol opened this issue Jun 16, 2023 · 2 comments · Fixed by django-webpack/webpack-bundle-tracker#119 or #384
Closed

Support publicPath: "auto" #350

caseyjhol opened this issue Jun 16, 2023 · 2 comments · Fixed by django-webpack/webpack-bundle-tracker#119 or #384

Comments

@caseyjhol
Copy link

caseyjhol commented Jun 16, 2023

Currently, setting publicPath: "auto" results in a stats file with:

{
  "status": "done",
  "assets": {
    "lib/css/layers.416d91365b44e4b4f477.png": {
      "name": "lib/css/layers.416d91365b44e4b4f477.png",
      "path": "/Users/casey/build/public/lib/css/layers.416d91365b44e4b4f477.png",
      "publicPath": "autolib/css/layers.416d91365b44e4b4f477.png"
    },
    ...
}

"auto" is just prepended to publicPath. Which of course won't work out of the box. Considering "auto" is the default value in Webpack, it might be nice to support setting publicPath: "auto" and add a PUBLIC_PATH option to the loader config that would handle concatenation for us. We're using a custom LOADER_CLASS in the meantime.

@fjsj
Copy link
Member

fjsj commented Nov 29, 2023

@caseyjhol, I agree this would be the best. Can you share your custom LOADER_CLASS?

@fjsj
Copy link
Member

fjsj commented Dec 1, 2023

@caseyjhol I've made some changes add support for publicPath: "auto". I tested it in production with a S3 config, but it would be good if you also test it.

Install the fixes (not released yet):

npm install "git+https://github.com/django-webpack/webpack-bundle-tracker.git#8d761d9cfb6c7f9a35ace90baba1fb02fbdc717e"
pip install "git+https://github.com/django-webpack/django-webpack-loader.git#abdd5c72b1de6c4815cc4d86b4621d9c2104f426"

Use a output like:

const path = require("path");

module.exports = {
  // ...
  output: {
    path: path.resolve("./frontend/webpack_bundles/"),
    publicPath: "auto",
    filename: "[name]-[chunkhash].js",
  },
};

and let me know if it works for your use case.

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