-
-
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
Shared js file and missing style link #2340
Comments
I've been digging a bit, and I've found where the bug occurs. Here, the bundler rejects creating a new bundle for the I'm not sure how to fix the issue, but at that point, somehow the asset must still be registered on the bundle, so that the lookup here can find it. |
Any updates? If I'm not mistaken, the current work around is to create an index for each entry point? |
package any pug files meet the same issue. |
any news? Temp solution:
src/shared.js import "./styles.scss";
import "jquery/dist/jquery.slim.js";
import "bootstrap"; src/pages/about.js import "../shared.js"; src/pages/about.html <script src="about.js"></script> src/pages/index.js import "../shared.js"; src/pages/index.html <script src="index.js"></script> |
I have the same issue. The solution that @maximelebreton suggested kind of helped me for now, but I prefer to keep all pages on the first layer of src/, so my structure looks like this:
Where in index.js I have all asset imports, and if I want to create some other page, I add page2.html and link to an auxiliary page2.js file with the only line inside Unfortunately you need to create the specific js linker file for an every new html page. It may make the src/ folder kind of messy, so I tidy up them to some folder. But at least for me the advantage will be that urls remain more obvious. |
@mischnic The original issue was reported more than a year ago. Any update so far? |
@sergeyzwezdin I've just tested this with Parcel 2, it's fixed. |
@mischnic When it's going to be published? |
The current alpha version works as expected. |
@mischnic ok, but when it will be published as a stable version? I wouldn't like to use alpha. |
Which one is it please? I've tried 2.0.0-nightly.85 - not working. |
@equistx Please provide a (small) code sample |
index.js: cmd: |
@mischnic I'm sorry and thank you, my fault, it is working. I've been using wrong version, because I had somehow Unfortunately I can't use working alpha, since HMR stopped working after I switched from |
As suggested here, I had to remove the |
After some time, I got back to this. Unfortunately, issue is still there on |
-> #3708 |
still having the same issue on the last 1.x version |
how is it possible that such a foundational bug that prevents anyone from building multi-page sites hasen't been solver in almost two years? |
I also have this issue best work around for me was to load the css as string and append it to the html myself using |
You're getting this with Parcel 2 as well? |
@micopc I am using 1.12.4 the latest stable. (just tried with v2 that has a temp problem "Name already registered with serializer") update2: does not work with NPM on v2 but does with yarn if this is any help |
Doesn't solve the issue for me. If you have two simple documents pointing to one another, it will follow a.href and try to make sense of the other doc and fail. if… meodai.html links to home.html it still produces unpredictable results with CSS and JS sometimes working and sometimes not. As soon as I have multiple files I start getting CSS error messages like "Uncaught SyntaxError: Unexpected token ':'. |
Read this: #3008 One part of the issue might be connected with including inline style in html file/s. Do not include any inline style in your html files! Combining @maximelebreton solution and removing inline style elements solved my problems. I am able to have multiple page setup with correctly included shared css or js files. For completeness here is my package.json file, note that it does not require including the other pages (.html files) in any parcel script, it is enough to reference the page in a simple href attribute, such as
My starting project is html5boilerplate |
problem still not solved? |
Till now, there is still no specific fix for this issue. Wild |
This should already be working in Parcel 2. |
It is unbelievable that a bug this bad still isn't solved even 4 years later. |
Please provide a reproduction. |
My bad; I thought this issue was causing me problems. I think it's another problem. I'm creating an issue for that. |
🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
package.json
build.js
src/index.html
src/index2.html
src/index.js
src/index.css
🤔 Expected Behavior
The same css file should be linked to both dist/index.html dist/index2.html
😯 Current Behavior
dist/index.html
dist/index2.html
The css file is lined only to index.html and not to index2.html
🌍 Your Environment
The text was updated successfully, but these errors were encountered: