Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run production build locally using webpack server?

I am using webpack-dev-server locally to build my application. I have configure it properly and on running command "yarn build" its generating files into /dist/ folder.

Is there any way I can use the dist folder locally using the webpack-dev-server? The idea is I need to run multiple versions of my application locally to test few stuf.

like image 265
coure2011 Avatar asked Mar 26 '19 14:03

coure2011


People also ask

How do I run a webpack project locally?

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.

Is webpack used in production?

Webpack v4+ will minify your code by default in production mode . Note that while the TerserPlugin is a great place to start for minification and being used by default, there are other options out there: ClosureWebpackPlugin.


1 Answers

You need a server to serve your generated dist folder.

You can use (https://www.npmjs.com/package/http-server):

npm install -g http-server

Jump into your dist folder and run:

http-server
like image 69
Daniel Richter Avatar answered Oct 03 '22 22:10

Daniel Richter