Comments (6)
A temporary workaround that (1) finds all .html files in the source folder and (2) iterates over them, creating nested builds so that pages can be loaded using url directories like "www.example.com/testing/" and not "www.exmple.com/testing.html":
import esbuild from "esbuild";
import htmlPlugin from "@chialab/esbuild-plugin-html";
import findFiles from './findFiles.js'; // adapted from: https://stackoverflow.com/a/47900452/14198287
let files = findFiles('./src', '.html');
for (let f in files) {
let file = files[f];
let dir = file.split('/').slice(-2)[0];
await esbuild.build({
entryPoints: [file],
outdir: `public/${dir === 'src' ? '' : dir}`,
plugins: [htmlPlugin()],
assetNames: "[name]",
bundle: true,
minify: true,
write: true,
});
};
This only works for directories 1-level deep into the src directory tree, but suits my needs for now. It's the best solution I could think of up, the main drawback being that any shared js files, assets, etc. are not shared between pages.
from rna.
Also running into this problem, which makes multi-entrypoint builds impossible with a single config as expected.
Ends up with any bundles after the first pointing to the first as their targeted js, which means they all render the same app.
According to the docs, it should work with [dir]
in the *Names
options: https://esbuild.github.io/api/#entry-names
from rna.
Hello @harleylang and @nerdfoundrygaming
we finally managed to release a version (0.15.17) that should handle the case. Can you help us in testing it? There may be some edge cases we missed. Thank you!
from rna.
Thanks @edoardocavazza !! I just tested with 0.15.17.
I can report that my nested route compiled, however I am receiving an absolute path for the assets within my root index.html file.
config:
await esbuild.build({
entryPoints: ["src/index.html","src/study/index.html"],
entryNames: '[dir]/[name]',
outdir: "public",
outbase: "src",
plugins: [htmlPlugin()],
assetNames: "[dir]/[name]",
bundle: true,
minify: true,
write: true,
});
from rna.
I see. Version 0.15.20 has a fix for that 🤞
from rna.
Closing as this is sorted on my end both locally and in production. Thank you @edoardocavazza !!
from rna.
Related Issues (20)
- wtr-mocha-reporter - when web-test-runner run in watch mode does not finish running tests HOT 2
- Wrong path for CSS assets HOT 2
- Can't use assets in a SPA without proxy HOT 2
- bad path separator for assets HOT 3
- [esbuild-plugin-html] Load style files without script HOT 4
- [esbuild-plugin-alias] Align with esbuild builtin alias management HOT 1
- esbuild-plugin-html does not use the original directory of the source file HOT 6
- esbuild-plugin-meta-url only transforms node_modules? HOT 1
- document how to interop normal esbuild plugin with esbuild-rna plugin HOT 2
- Unable to specify an output directory with esbuild-plugin-meta-url HOT 3
- Feature Request: Single Page Application support for the HTML plugin. HOT 1
- feat: [esbuild-plugin-html] Support esbuild `publicPath` HOT 1
- SyntaxError: Identifier '__filename' has already been declared HOT 3
- Weird behavior when not using `hash`
- SourceMapNode is not a constructor HOT 3
- Minimize html
- Error with `require-resolve` HOT 2
- esbuild-plugin-html only watches the HTML file HOT 7
- React example? To replace react-scripts build HOT 10
- Windows bug in `esbuild-plugin-html` - Not escaping backslashes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rna.