Webpack-dev-server: CommonsChunkPlugin not working with webpack-dev-server?

Created on 6 Dec 2014  Â·  9Comments  Â·  Source: webpack/webpack-dev-server

Hi,

First I have to give creds for a fantastic job on this tool! It seems to be getting even more traction now that Facebook backing up with more "get going" documentation. At least that got me started :-)

Anyways, this is my config file. My goal is to optimize rebundling speed as I am using React JS and it adds a lot to the dependency tree.

var webpack = require('webpack');
var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js');

module.exports = {
  entry: ['webpack/hot/dev-server', './app/main.js'],
  output: {
    path: './build',
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      { test: /\.js$/, loader: 'jsx-loader' },
      { test: /\.css$/, loader: 'style-loader!css-loader' }
    ]
  },
  plugins: [commonsPlugin]
};

If I run webpack-dev-server --progress --colors -d --hot I get a Uncaught ReferenceError: webpackJsonp is not defined when loading the app. I can not see that a common.js file is being put into my /build folder either. But, if I do this: webpack ./app/main.js --progress --colors (using normal webpack), it builds the common.js file and everything seems to work just fine.

I though maybe this issue might help, but I have not had any luck with it. I was hoping you had some pointers to what I am doing wrong.

Thanks for any help!

Most helpful comment

is being put into my /build folder either

the dev-server bundles in memory.

Uncaught ReferenceError: webpackJsonp is not defined

You need to include a <script> tag to the common.js file in the HTML.

All 9 comments

is being put into my /build folder either

the dev-server bundles in memory.

Uncaught ReferenceError: webpackJsonp is not defined

You need to include a <script> tag to the common.js file in the HTML.

Aha, that explains it :-) But how to I change the html file launched by
dev-server, it creates this "behind the scenes by default"

Thanks for the help!

On Saturday, December 6, 2014, Tobias Koppers [email protected]
wrote:

is being put into my /build folder either

the dev-server bundles in memory.

Uncaught ReferenceError: webpackJsonp is not defined

You need to include a

Related issues

mischkl picture mischkl  Â·  3Comments

eyakcn picture eyakcn  Â·  3Comments

da2018 picture da2018  Â·  3Comments

antoinerousseau picture antoinerousseau  Â·  3Comments

movie4 picture movie4  Â·  3Comments