DEV Community

Cover image for Building a basic website with Parcel

Building a basic website with Parcel

Craig Holliday on October 15, 2020

You want to build a tiny website with just HTML, CSS, and JavaScript. You don't want to import a ton of libraries or use a framework that performs ...
Collapse
 
yoursunny profile image
Junxiao Shi

My main complaint about Parcel is the "regenerate runtime" error that pops up in the browser. Parcel doesn't use a configuration file, but this really means that configuration is scattered around in babelrc and browserslist.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

But you did realize the solution? Either really install and import regenerator-runtime; or set browserslist higher.

Collapse
 
yoursunny profile image
Junxiao Shi

Yes, I changed browserslist - but it's mentioned nowhere in Parcel documentation.

Thread Thread
 
patarapolw profile image
Pacharapol Withayasakpunt

It's a known bug (in GitHub issues), and very common too; but Parcel team seems to be too busy to fix it.

Collapse
 
leob profile image
leob • Edited

Would be interesting if you could elaborate what's the absolute minimum required CSS for a "working" website, such as CSS resets, typography, color scheme, responsive/grid, viewport settings etc.

I see so many people advocating "don't use a CSS framework, roll your own" but I'd like to see the required minimum CSS for a real world website demoed and explained somewhere.

Collapse
 
wannabehexagon profile image
ItsThatHexagonGuy

Rolling your own "css framework" would be feasible if the product is fairly small or you have the required human resources to produce a maintainable, easy to use and well-documented stylesheet.

There is absololutely no harm in using a css framework and I personally don't think its even a remotely good idea to "roll your own" unless the aforementioned conditions have been met.

Maintaining css can be pretty annoying after all.

Collapse
 
craigaholliday profile image
Craig Holliday

I agree with Mydrax that there is no reason not to use a good CSS framework nowadays.
For just minimal CSS for an MVP I'd use this bare minimum stylesheet:
github.com/andybrewer/mvp

Collapse
 
micahlt profile image
Micah Lindley

Nice post! I've used Parcel since 2019 when a friend introduced me, and it's my favorite bundler. This is an awesome tutorial, however I would add two things. 1) Technically, JavaScript does provide a way to import and export code (in recent ES6), it's just not well supported. 2) Vercel is also a great place to host and even build Parcel sites in the cloud. Love your writing style as well! Have a great day 👋

Collapse
 
craigaholliday profile image
Craig Holliday

Great addition! Funny enough after I wrote this I took a look at the new ES6 way of importing and exporting code as well as deployed an app with Vercel!
Thanks!

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Why on earth would you use a bundler for a project of this size? Better still, just use native import features to pull in dependencies from a CDN like SkyPack (e.g. import moment from 'https://cdn.skypack.dev/moment'). If everyone loaded dependencies like this, the web could become much faster as many, many libs would be cached in browsers

Collapse
 
insanenaman profile image
Naman Gupta

Wow thats great. Some days back, I also made this small starter kit for static websites using Parcel. You can read about it here - dev.to/insanenaman/starter-kit-for...

Collapse
 
craigaholliday profile image
Craig Holliday

That's great! I really like how your post was put together 👍

Collapse
 
insanenaman profile image
Naman Gupta

Glad you liked it.

Collapse
 
shamimahossai13 profile image
Shamima Hossain

Thanks a lot I was struggling with understand what and why a bundler is used in a project ..your post helped clear out some confusions. The project that i'm working on uses Webpack...do you think parcel works good for projects of medium to large codebase?

Collapse
 
craigaholliday profile image
Craig Holliday

Pacharapol is spot on.
Parcel is faster and has some configuration (that I have not looked into deeply) but I have not tried it for my larger projects.

Webpack is not going away and is still great to use for any project of medium to large size. Mainly I would stick with anything that is working and try Parcel when you have a chance to experiment without breaking anything.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

Parcel is supposedly faster than Webpack, but may sacrifice configurations.

And esbuild is even faster, but much less features.

Collapse
 
yoursunny profile image
Junxiao Shi

moment is now "legacy" because it lacks tree shaking. Don't use it.

Collapse
 
craigaholliday profile image
Craig Holliday

Yep in the new example code I went ahead and used Day.js. Great newer alternative.

Collapse
 
wannabehexagon profile image
ItsThatHexagonGuy

I've used parcel in a few side projects and I love the fact it takes little to nothing to get started!

Collapse
 
louislow profile image
Louis Low

Ahh... Looks pretty nice though. My favorite Static-Site-Generator by using Markdown is 11ty. I would give it a try. Thanks.

Collapse
 
codebubb profile image
James Bubb

Yes! Love Parcel. You can also use import/export keywords within your JavaScript source; Parcel will take care of these and transpile it down into something the browser can work with.

Collapse
 
craigaholliday profile image
Craig Holliday

Yea! So easy to use and love using the import syntax

Collapse
 
alfredosalzillo profile image
Alfredo Salzillo • Edited

JavaScript does not provide a way to import code from one file to another.

What about es6 static and dynamic import?

Collapse
 
craigaholliday profile image
Craig Holliday

This is true. I'd say I'm a bit behind on some of the newest features so I should make a post just about importing and exporting in ES6.

Collapse
 
rashdowdev profile image
Raseed Hassan

Pls is it only the dust file that gets deployed on the web server?