VladimirMikulic / parcel-plugin-custom-dist-structure

🚀 Parcel plugin that allows you to specify a custom dist structure.
https://www.npmjs.com/package/parcel-plugin-custom-dist-structure
MIT License
104 stars 6 forks source link

Wrong absolute path for dependencies when public url specified #19

Closed imamatory closed 4 years ago

imamatory commented 4 years ago

Hi. This is awesome plugin i really like it but i found it a bit strange that --public-url parcel param doesn't appear in resulting url. I looked at the plugin code and realised that this behavior is intentional. So the question is how can i put public url in dependencies href or src? Should it be treated as a bug?

my config in package.json

  "customDistStructure": {
    "config": {
      "pages": [
        ".html"
      ],
      "js": [
        ".js",
        ".js.map"
      ],
      "styles": [
        ".css",
        ".css.map"
      ],
      "images": [
        ".jpg",
        ".png"
      ]
    },
    "options": {
      "development": true
    }
  }
VladimirMikulic commented 4 years ago

Hi @imamatory. I am not sure if I understand your question. --public-url flag specifies how assets are referenced (served).

If it is / than your dist folder is treated as a base point. On the other hand, if it is ./, then it's a relative path to the asset.

Which public-url did you specify?

We'll resolve this, don't worry. Just describe to me what your goal is (i.e. what were you trying to accomplish)?

Thank you :)

imamatory commented 4 years ago

I am trying to specify static url prefix because it vary in different environments. In my case it is /static/. The problem is that i build django templates rather than static html that may be served via relative paths. So i need to specify absolute urls in html templates

VladimirMikulic commented 4 years ago

I think I got it now, instead of typical / or ./ you would like a custom public-url. As of now, this is not possible. I'll start working on this as soon as I resolve the bug on Windows.

Thank you for your patience and understanding.

imamatory commented 4 years ago

That's great! Will wait.

On Wed, May 6, 2020, 3:03 AM Vladimir Mikulic notifications@github.com wrote:

I think I got it now, instead of typical / or ./ you would like a custom public-url. As of now, this is not possible. I'll start working on this as soon as I resolve the bug on Windows.

Thank you for your patience and understanding.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/VladimirMikulic/parcel-plugin-custom-dist-structure/issues/19#issuecomment-624368900, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIAURCCSYXGT5VI4X4DG7LRQCSMLANCNFSM4MZ7NUPA .

VladimirMikulic commented 4 years ago

Hi @jedchang. I think I've fixed it, but I'll need your help to verify this :)

I would like you to test it, the steps are:

  1. Clone the project: git clone https://github.com/VladimirMikulic/parcel-plugin-custom-dist-structure.git
  2. Check out the test branch: git checkout feature/custom-absolute-public-url
  3. Install dependencies: npm i
  4. Make it available globally on your system: npm link
  5. After running npm link, you'll get the absolute path to the package -> copy it
  6. Enter your project and run npm i -D to install the plugin (before this, make sure to delete the version from NPM)
  7. Report the results here

Thank you.

imamatory commented 4 years ago

Yeah! It works awesome!

VladimirMikulic commented 4 years ago

@imamatory that's good to hear! I've published a new version v1.1.10 which includes this change.

Also, thank you for mentioning npm i. I should've specified it :) Enjoy :rocket:

imamatory commented 4 years ago

I've used yarn so i decided that with linking via npm npm i may not be necessary. Thank you! You've kept me with parcel :+1:

VladimirMikulic commented 4 years ago

No problem. I am a big fan of Parcel and zero-config approach. Webpack is a necessity for bigger projects, but for side projects and even sm-mid size production apps Parcel serves just fine! Glad you like it :)