J
J
jspie2017-08-26 13:47:06
webpack
jspie, 2017-08-26 13:47:06

How to use webpack in production?

Hello, I'm a little confused with webpack. I am using webpack-dev-middleware:

const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');

const compiler = webpack(webpackConfig);

app.use(webpackDevMiddleware(compiler,{
  stats:{
    colors: true,
        hash: false,
        timings: true,
        chunks: false,
        chunkModules: false,
        modules: false
  }
}));
app.use(webpackHotMiddleware(compiler));

In production on the server, webpackDevMiddleware can no longer be used?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-08-26
@jspie

In production, you need a scripts and styles file.
Therefore, you call webpack -p(minus p tells webpack: generate a real bundle.js file and what else you specify) and put the finished file (s) on your server / hosting, etc. There is already at least apache, at least nginx, at least anything distributing statics.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question