I am following the basic tutorial for Parcel to bundle js, css and image files.
My file structure
dist
node_modules
src
- index.html
- style.css
- index.js
- somemodule.js
When I run parcel ./src/index.html
a server is started and the website is displayed correctly. According to the tutorial you can finalize the build using parcel build index.js
. I expected to get this output:
dist
- style.css
- index.js
- index.html
But instead, after running parcel build index.js
I get this output:
dist
- 4wyd98y98790.css
- 948y59hslas8.js
What could possibly be going wrong?
I am following the basic tutorial for Parcel to bundle js, css and image files.
My file structure
dist
node_modules
src
- index.html
- style.css
- index.js
- somemodule.js
When I run parcel ./src/index.html
a server is started and the website is displayed correctly. According to the tutorial you can finalize the build using parcel build index.js
. I expected to get this output:
dist
- style.css
- index.js
- index.html
But instead, after running parcel build index.js
I get this output:
dist
- 4wyd98y98790.css
- 948y59hslas8.js
What could possibly be going wrong?
Share Improve this question edited Dec 27, 2017 at 14:13 Josh Unger 7,1637 gold badges37 silver badges55 bronze badges asked Dec 19, 2017 at 23:07 KokodokoKokodoko 28.1k36 gold badges131 silver badges204 bronze badges4 Answers
Reset to default 6The Parcel Bundler output directory is dist
by default, but you can specify an output directory by setting option (-d
).
e.g.parcel build src/index.html -d build --public-url .
You will get the final static files in the build directory.
The tutorial may say parcel build index.js
, but you should run parcel build ./src/index.html
. The entry point of your app is index.html.
Since some commands seem to change over time, I'm going to share here the set up that worked for me up to date.
"scripts": {
"start": "parcel src/index.html -p 3000 --open",
"build:parcel": "parcel build ./src/index.html --public-url ./ --no-source-maps",
"build": "npm run clean && npm run build:parcel",
"clean": "rm -rf dist/*"
}
And I run the script using npm run-script build
My tree project was:
project
|dist
|OUTPUT FILES
|src
|OTHER INPUT FOLDERS
|index.html
package.json
Try to remove old build stuff like dist
folder and build again. It should work.
But if it doen't then delete dist
as well as .parcel-cache
folder. Than build again. It should work.