简体   繁体   中英

HowTo move from dev to production from webpack-dev-server

This is my devs webpack.config file:

var webpack = require('webpack');
var webpackMerge = require('webpack-merge');
//var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
var env = require('../environments/prod.env.js');

module.exports = webpackMerge(commonConfig, {
  devtool: 'source-map',

  output: {
    path: helpers.root('server', 'public', 'static', 'js'),
    filename: '[name].js'
  },

  plugins: [

    new webpack.DefinePlugin({
      'process.env': env
    })
  ]
});

This webpack gist ( https://github.com/dmachat/angular-webpack-cookbook/wiki/Deploy-to-production ) says I can use the same file, only webpack start up is different. Can somebody help me?

relevant parts from the package.json:

  "scripts": {
    "build": "webpack --progress --config config/webpack.dev.js",
    "build:prod": "webpack --progress --config config/webpack.prod.js",
    "postinstall": "typings install",
    "serve": "webpack-dev-server --inline --progress --port 8080",
 ...

I think you are asking how to make web-pack-dev server host your production build instead of your dev build?

Let's say you have a directory called build. You would point webpack-dev-server to serve the files in that directory like so "--content-base build/"

Also will probably find that you want to set NODE_ENV=production in your production build script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM