Skip to content
This repository was archived by the owner on Jun 7, 2019. It is now read-only.
This repository was archived by the owner on Jun 7, 2019. It is now read-only.

Is it possible to support pug assets root path #4

@huanglong-zz

Description

@huanglong-zz

Parcel-plugin-pug is really handy to use. However, when it comes to production, something inconvenient come out.

Here is the pug project:

. project
├── bin
│   └── build
├── package-lock.json
├── package.json
├── public
│   └── js
│       ├── detail.js
│       └── index.js
└── server
    ├── index.js
    └── views
        ├── assets
        │   ├── script.pug
        │   └── script2.pug
        ├── detail.pug
        └── index.pug
  • server/index.js with koa/koa-static always return html page rendered by pug engine
  • public will have a dist to serve in production
  • bin/build run the parcel build task to compile assets/*.pug which only have css/js

In development:

In production:

But parcel always compile files recording to the relative path which is defined in server/views/assets, that means it has to be ../../../public/js/index.js.

So the only way I found is always using /js/index.js /js/detail.js instead.

Then I think maybe parcel-plugin-pug could nest this config for this compiling case. It will treat anything normal just like before, but when it meets some assets where the path start with /, it will know all the relative files is relative to public/.

Here is the repo: https://github.com/huanglong/parcer-bundle-test

npm run start for development
npm run build for build
npm run production for both build and production

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions