Skip to content

Not rebuilding/rebundling automatically #558

@lukejagodzinski

Description

@lukejagodzinski

Hi, I'm trying to use webpack-dev-server to have hot code reloads but without a success. I'm 100% sure that I've configured everything correctly. I've tried many different approaches but my project does not get rebuild and bundled automatically. I have to run webpack by hand to generate/bundle correct code.

Here is my webpack.config.js file:

var debug = process.env.NODE_ENV !== 'production';
var webpack = require('webpack');

module.exports = {
  context: __dirname,
  devtool: debug ? 'inline-sourcemap' : null,
  entry: './js/main.js',
  module: {
    loaders: [{
      test: /.js?$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      query: {
        presets: ['es2015', 'react', 'stage-0'],
        plugins: [
          // Static class properties.
          'transform-class-properties',
          // Share Babel helpers among files - smaller file size.
          'transform-runtime'
        ]
      }
    }]
  },
  output: {
    path: __dirname + '/js',
    filename: 'main.min.js'
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      mangle: false,
      sourcemap: false
    })
  ]
};

And packages.json

{
  "name": "NextGen",
  "version": "1.0.0",
  "scripts": {
    "start": "./node_modules/.bin/webpack-dev-server --port 3000 --inline --hot"
  },
  "author": "Łukasz Jagodziński",
  "license": "ISC",
  "dependencies": {
    "react": "^15.3.1",
    "react-dom": "^15.3.1"
  },
  "devDependencies": {
    "babel-core": "^6.13.2",
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-class-properties": "^6.11.5",
    "babel-plugin-transform-runtime": "^6.12.0",
    "babel-preset-es2015": "^6.13.2",
    "babel-preset-react": "^6.11.1",
    "babel-preset-stage-0": "^6.5.0",
    "babel-runtime": "^6.11.6",
    "webpack": "^1.13.2",
    "webpack-dev-server": "^1.15.0"
  }
}

It does not matter if I go to http://localhost:3000/ or http://localhost:3000/webpack-dev-server/. When I make a change I get info in the console that correct files were updated but browser does not refresh. What is even worse it also does not update to the new state when I refresh it by hand. So I've checked if the output file is correctly generated. And it's not. I have to run webpack command by hand and refresh browser. My on OS X El Capitan 10.11.6. Have anyone experienced such a problem?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions