I got ParcelJS project with multiple package.json
file scripts commands.
"scripts": {
"parcel": "./node_modules/@mms/parcel-bundler/bin/cli.js",
"start": "parcel templates/layouts/index.pug",
"start:news": "parcel templates/layouts/news.pug",
"start:news-inner": "parcel templates/layouts/news-inner.pug",
more and more commads here...
}
The package.json
file above works fine but it's become bigger and unreadable as the project is growing up.
So I want to compress package.json
scripts block by remove all :postfix
pages names and pass the necessary page name as NPM arguments with alternative fallback page name at, if there is no page specified
Sample of expected code:
"scripts": {
"parcel": "./node_modules/@mms/parcel-bundler/bin/cli.js",
"start": "parcel templates/layouts/\"$1 || index\".pug"
}
Of course the example above isn't working because it has syntax problems, so as the first steps I tried the simpler code below, and it's not working too, and I don't know why.
"scripts": {
"parcel": "./node_modules/@mms/parcel-bundler/bin/cli.js",
"start": "parcel templates/layouts/\"$1\".pug"
}
Terminal result of the above script runing:
$ yarn start index
yarn run v1.19.1
$ parcel templates/layouts/"${1}".pug index
Server running at http://localhost:1234
No entries found.
error Command failed with exit code 1.
Could you please help me to fix this NPM script?