How to run production build locally using webpack server? - webpack-dev-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.

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

Related

is there anyway to start reactjs after build bundle?

I built my reactjs website with these command:
npm run build
After that, build folder is generated. To start server:
npm install -g serve
serve -s build
I want to run my react app background. Since i have no file *.js like:
nodemon lib/index.js --exec babel-node --presets=es2015,stage-2
from How to use nodemon in npm scripts to build and start scripts?
Any hint would be appreciated from my heart.
Thank a lot.

is there any way that I can serve my ".next" folder without using next.js?

I know how to reduce the size, I should remove dev time dependencies, another option is easy to find on the internet. But the real question comes while serving the next.js app. I deploy the website on production through pm2 using next start. What is really happening is that next start won't work without dev dependencies and which affects the size of the docker image. Is there any way that I can serve my .next folder without using next.js? This will reduce the massive size of the docker image.
You can use yarn install --production=true to ignore devDependencies and only install regular dependencies.
Using this, you can install production dependencies first in a temporary folder, then copy the dependencies to the app folder and remove the temp folder.
Here's an example Dockerfile:
# Install production dependencies
WORKDIR /tmp/app
COPY ./package.json ./package.json
COPY ./yarn.lock ./yarn.lock
RUN yarn install --production=true
RUN mkdir -p /home/node/web && cp -a ./node_modules /home/node/web/
# Build project
COPY . .
RUN yarn install --production=false
RUN yarn run build
RUN cp -a ./dist /home/node/web/
# Clean up
RUN rm -rf /tmp/app
# Run next app
WORKDIR /home/node/web
CMD NODE_ENV=production ./node_modules/.bin/next

Angularjs Project run localmachine

I wanna run this project using Node.js. I have already installed it. But I don't know how to run it in my local system. Any help is appriciated.
install a simple http-server by following command
npm install -g http-server
go to project main folder where index.html exists and run command
http-server
You can start your project at locathost:8080

Npm run build not creating build folder

I have a react application, and in the past I have successfully deployed it to surge.sh by running npm run build and then running the surge command from inside the build folder. I made one small change to the scss file, and now when I run npm run build, there is no build folder being created so I can't deploy the app. Does anyone know what could be going on?

How to run "Grunt serve" command on live hosting?

I have made one angular app. this app in use grunt and run application using "Grunt Serve" command. But, I have uploads this application on live hosting. so, please help me... How to run "Grunt serve" command on live hosting?
Achieve that by following steps:
Make sure node.js is installed on hosting instance
Make sure you app has proper package.json that contains grunt
dependencies used by your app
Connect to host machine and run npm install (via putty or ssh or
....)
After packages are installed you can run grunt serve manually or you
can put that command in postinstall script of package.json to auto
run after npm install is done

Resources