Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What does webpack-dev-server serve when the bundle exists in both output folder and memory? #398

Closed
jiayihu opened this issue Feb 8, 2016 · 3 comments

Comments

@jiayihu
Copy link

jiayihu commented Feb 8, 2016

Using this config webpack-dev-server will serve the static files in your build folder. It'll watch your source files for changes and when changes are made the bundle will be recompiled. This modified bundle is served from memory at the relative path specified in publicPath (see API). It will not be written to your configured output directory. Where a bundle already exists at the same url path the bundle in memory will take precedence (by default).

From the doc the bundle in memory should be the one served, but in my experience the bundle contained in the output folder and written by webpack --watch is actually served. Is it correct?
I'd be happy to update the docs to reflect whatever goes on.

@zhangmengxue
Copy link

@jiayihu Hi,What do you mean?
In my experience , the bundle in the output path doesn't served when modified .It seems not be written to my configured output directory. I still couldn't find a way out.
Now,when i change something, I have to control+C & webpack &webpack-dev-server.
er....
this is my webpack.config.js:


var webpack = require('webpack');
var path = require('path');
var ROOT_PATH = path.resolve(__dirname);
var HtmlwebpackPlugin = require('html-webpack-plugin');

module.exports = {

  entry: [
    'webpack/hot/dev-server',
     path.resolve(ROOT_PATH, 'www/src/p/index.js')
  ],

  output: {
    path: path.resolve(ROOT_PATH, 'www/build'),
    filename: 'bundle.js'
  },

  module: {
    loaders: [
        { test: /\.css$/, loader: "style!css" },
        {test: /\.less/,loader: 'style-loader!css-loader!less-loader'},
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: "babel-loader",
          query:
          {
            presets:['react']
          }
        }
    ]
  },

  resolve:{
      extensions:['','.js','.json']
  },

  devServer: {
    contentBase: path.resolve(ROOT_PATH,'www/build'),
    hot: true,
    inline: true,
    historyApiFallback: false
  },

  plugins: [
    new webpack.NoErrorsPlugin(),
    new webpack.HotModuleReplacementPlugin(),
    new HtmlwebpackPlugin({
      title: 'Task'
    })
  ]
};

@jiayihu
Copy link
Author

jiayihu commented Feb 18, 2016

@zhangmengxue thanks for your reply! I already solved the problem and it was my fault, since I wrote the wrong src path when including the script in my HTML file. Therefore it loaded the script in the disk meanwhile the one in the memory was also available on a different path.
I thought it was an issue because someone else already had the same problem (from a quick search on Google) and no solution was provided.
I'm going to close this issue.

@jiayihu jiayihu closed this as completed Feb 18, 2016
@zhangmengxue
Copy link

ok, I was figure out this through https://webpack.github.io/docs/webpack-dev-server.html#combining-with-an-existing-server . actually , where is the newest bundle.js file is the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants