I am currently using require.js
for development so I can iterate quickly (change a file, refresh page, no build step in between), but I use webpack
as a build tool since it is superior to r.js
. I would like to get rid of require.js entirely and use webpack as a script loader in development. I know that's exactly what webpack dev server
is for, but I specifically don't want to use it.
Ideally I would just include some kind of webpack loader in <script>
, point it to my webpack.js
build config, and let it do the job.
So that you don't have to spin up other servers like node to see your project locally, webpack dev server provides you a port number where you can see or test your project in the browser locally. When you run webpack dev server what webpack dev server does is, instead of creating a bundled file ( e.g. bundle.
To run the local installation of webpack you can access its binary version as node_modules/. bin/webpack . Alternatively, if you are using npm v5. 2.0 or greater, you can run npx webpack to do it.
Out of the box, webpack won't require you to use a configuration file. However, it will assume the entry point of your project is src/index.js and will output the result in dist/main.js minified and optimized for production.
The Ecosystem now The newer bundlers have simpler configuration, allowing people to add/create plugins and configure the setup more easily, and some utilize ESM to make ultra fast reload speeds and smaller bundles. Because of this, Webpack is not the best tool to use anymore.
If you don't want to use webpack-dev-server, you could use webpack's watch functionality to keep building your script as you make changes. That will give you the workflow you're looking for. In the index.html, you'll be including your bundle only and no loader.
http://webpack.github.io/docs/tutorials/getting-started/#watch-mode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With