-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[RFC] A way to include stylesheets/scripts in html without bundling them #1087
Comments
I really like the |
I like this, I think it would be super useful |
A way to have Parcel ignore some linked files is needed. However, I don't think it is a good way to add info in HTML files for this. Just keep HTML for you business, without anything for building. Consider other ways,maybe:
|
I had a need to ignore some script tags that were pointing the absolute path and found this issue. https://github.com/Joe-Withey/parcel-plugin-html-root-syntax |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions. |
The plugin doesn't work for me (with parcel 1.12.4), there is an error:
For my need, I found the following solution: Instead of <link rel="icon" href="/favicon.png"> I write <script>document.write(`<link rel="icon" href="/favicon.png">`)</script> Not good, but works. |
Could a member/author close either this issue with wontfix or add it a roadmap, and maybe add a comment for whether this feature will exist in v2? |
I think something like <script data-parcel-ignore>
// ...
</script> would make sense |
I've made a plugin that excludes assets from bundling in Parcel 2.
{
"extends": "@parcel/config-default",
"resolvers": ["parcel-resolver-ignore", "..."]
}
{
"parcelIgnore": [
"bootstrap.css"
]
} Good to go! No need to modify source files! |
Since there's a similar example above, here's a solution for who wants to include favicon.ico without changing its name: How to copy favicon.ico with Parcel 2
{
"extends": "@parcel/config-default",
"transformers": {
"favicon.ico": ["@parcel/transformer-raw"]
}
} And voilà:
|
@mischnic I think a more generic solution is to use comments:
<!-- parcel-ignore -->
<script src="some-static-file.js"></script>
<!-- parcel-ignore -->
<link href="bootstrap.css"></script>
<!-- parcel-ignore -->
<iframe src="../status.php"></iframe> But also: /* parcel-ignore */
@import '/some-external-file.css';
html {
background: papayawhip;
} /* parcel-ignore */
import('../my-local-file.js');
console.log('Loading from server'); |
Really glad I found this issue, as Parcel was having trouble with an HTML5 video source element despite saying videos are supported. I kept getting an error about "No transformer found for mp4" files. This worked in case anyone else lands here:
|
Parcel was trying to process the Plausible script (causing a build error), so we had to ignore it using a Parcel plugin. See parcel-bundler/parcel#1087
Parcel was trying to process the Plausible script (causing a build error), so we had to ignore it using a Parcel plugin. See parcel-bundler/parcel#1087
I've probably been waiting for a solution to this since the early days of Parcel. There is a number of reasons why I'd want a specific URL to be ignored by Parcel (i.e. left untouched) but there isn't. Today's attempt was to have Parcel ignore a call to a "local" dynamic API endpoint, like - <a href="/api/do-something">Do</a>
+ <form action="/api/do-something" method="get"><button>Do</button></form> I'm glad that |
I recently encountered an issue where a third-party javascript dependency wouldn't The file causing this issue had already been minified by the library maintainer. I really didn't need parcel to make any transforms, just copy the raw file to the dist folder. After a bit of digging, it turned out to be pretty easy to configure a {
"extends": "@parcel/config-default",
"transformers": {
"raw:*": [
"@parcel/transformer-raw"
]
},
"packagers": {
"raw:*": "@parcel/packager-raw"
},
"optimizers": {
"raw:*": []
}
} This allows you to reference json, scripts, etc without changing them. <html>
<head>
<link rel="preload" href="raw:emoji.json" as="fetch" />
<script src="raw:./a/b/c.js"></script>
... Hopefully this helps others. We could create a shared configuration distributed on npm if folks think this is a good way of handling this type of issue. |
RFC
Right now, Parcel will attempt to bundle all files referenced in
<link href=""/>
or<script src="">
tags in your html.I think it would be useful to have a way to have Parcel ignore some linked files. Specifically, cases where you are building or otherwise sourcing stylesheets separately from your Parcel build, but served from the same folder (or folder tree) as the bundled files. (Files served from other domains or referenced with
https://
are already ignored.)💁 Possible Solution
A possibly naive solution might be to add an identifying character (such as a "#") to the start of any paths/files Parcel should ignore, e.g.:
Parcel would simply strip the "#" out when building.
Another possible solution would be ignore comments:
I really don't have an opinion on the specific identifying character or comment format, these were just the first that I thought of to get the idea down.
🔦 Context
I came across this situation while attempting to work around using bootstrap.scss in a project with css-modules. More on that here. However, another reason might be needing to share a local stylesheet between the front and backend, and have it cache for both. You might do this if you have something like a custom Bootstrap build used on all pages (mostly rendered by the backend), including just a single page built with Parcel.
The text was updated successfully, but these errors were encountered: