Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Alternatively, you can use a simple web-server without needing all of webpack:

using npx (included with npm):

    npx serve .
using the php CLI:

    php -S localhost:5000 -t .
You weren't hitting the limits of vanilla JS, you were hitting the limit of reading files directly from disk instead of through a web server.


This is a good point, the fact that browsers won’t load JS modules over the file:// protocol is not the fault of JavaScript.


or in python 2 (should be on installed by default on most distro):

   python -m SimpleHTTPServer
or python3 :

    python -m http.server


Seriously, the poster is going to have to host their files somewhere eventually if they intend anyone else to ever see it. I can't believe they rewrote all their JS because they were forced to access over http:// instead of file://. This seems nonsensical.


Hey, never used python's http server, that's just as nice and easy as the two solutions I proposed, thanks for the tip!


A simple web-server only does that: serving a website. With a proper webpack setup, you get imports/exports, (node) module bundling, live reloading which all massively improve your development speed.

However I wouldn't recommend anyone to build their own webpack config if you don't know exactly what you're doing. Just use parcel: https://parceljs.org/


There's also Parcel: https://parceljs.org/

It does many things an advanced Webpack project does, but without any config. I use Parcel as long as possible and then switch to lower-level Webpack when I need more control. Easier way to start a new project.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: