What is the right way to add a demo page to a Parcel built library ? #8087
-
Hi ! I'd like to create a JS library (that has npm dependencies) and build it and publish it to NPM with Parcel. And I want to have a demo page that can be run very simply (it should behave like an app: serve all transitive dependencies). I'm wondering what is the right method to do so. I read https://parceljs.org/getting-started/library/ but it only shows how to build the package for npm (once with parcel build or when a file is modified with parcel watch). Is there a recommended approach ? Have a separate project ? or have files in the same project in a separate directory ? What parcel commands should be used to make all this work ? All this should probably be added to this documentation page, because developping a lib with only "parcel watch" or "parcel build" is almost impossible (the "getting started" lib has no tests). Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Either you create a new directory in a monorepo setup, or if you want everything to be in a single place, do something like {
// ...,
"main": "dist/index.js",
"module": "dist/index.mjs",
"targets": {
"app": {}
},
"scripts": {
"build": "parcel build src/index.js --target main --target module",
"start-demo": "parcel demo/index.html --target app"
}
} |
Beta Was this translation helpful? Give feedback.
Either you create a new directory in a monorepo setup, or if you want everything to be in a single place, do something like