Closed quantuminformation closed 8 years ago
Thanks @nathanborror for your hint about the Dropbox for Business's path convention, that solved it for me.
A project I used has below code
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const config = require('./webpack.config.dev');
const app = express();
const compiler = webpack(config);
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(compiler));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
It use npm run dev
to start, hot reload work on windows 8.1 but windows 7
What's the problem?
I don't know much about webpack, ..
webpack-dev-server --content-base ** --inline --hot * >> should be your output folder ./dist or wherever you are building the output
If you don't want to reload the page every time, for most platforms localhost:8080 is enough, else check in localhost:8080/webpack-dev-server/index.html
Here is the sample working app which I have created after two days of struggle. I have used the webpack dev server API method. https://github.com/Ajaybhardwaj7/webpack-react-sample
@QuantumInformation I have successfully launched recompiled file(not manually refresh), how? seting path to dist folder and devServer: { contentBase: "./dist", },
doing this
Moved from OS X to Windows 10 and now webpack-dev-server
is not detecting changes and rebuilding the bundle. I'm using Atom so there's no safe write, so that shouldn't be the problem.
I've attempted most solutions in this issue to no avail.
Here's my config see devServer
.
same here, i have the exact same problem with @synthecypher
Depending on what editor you're using, that could be causing the issue. Just found out that WebStorm was giving me this problem from Windows but not on Ubuntu (the settings must have been different on each).
The setting I had to disable which made all the difference was use "safe write"
(found in Appearance & Behaviour > System Settings), which saves changes first to a temporary file. Saving like that doesn't get picked up by webpack of course, was the cause of much frustration.
I can't get it to work either, everything loads fine but upon refresh auto or even manual it does not reflect updates. My config is: https://github.com/swimlane/angular2-data-table/blob/master/webpack.config.js
I've had the same problem with webpack 1.13.1 and webpack-dev-server 1.14.1 on Windows 10. Adding the following code to the webpack.config.js
file solved the issue:
plugins: [
new webpack.OldWatchingPlugin()
]
@Kekesed I managed to get it working it appears that it was caused by the paths not being correct for Windows. Wrap any applicable paths in path.resolve
and path.join
should do the job.
Here's the updated config feel free to clone my repo and test for yourselves.
This is what worked for me in windows 10:
//Webpack.config.js file:
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: path.join(__dirname, "src"),
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/client.js",
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
}
}
]
},
output: {
path: path.join(__dirname, '/src/'),
publicPath: '/src/', // instead of publicPath: '/build/'
filename: 'client.min.js'
},
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
],
};
Go to cmd and type: webpack-dev-server --watch-poll
This is my dir structure:
In browser go to: http://localhost:8080/webpack-dev-server/
Windows 10 - IntelliJ Ultimate (aka Webstrom) this solved it for me:
<< Depending on what editor you're using, that could be causing the issue. Just found out that WebStorm was giving me this problem from Windows but not on Ubuntu (the settings must have been different on each).
The setting I had to disable which made all the difference was use "safe write" (found in Appearance & Behaviour > System Settings), which saves changes first to a temporary file. Saving like that doesn't get picked up by webpack of course, was the cause of much frustration. >> Thanks to @lostpebble
Closing because there are several answers to the problem. Some of these issues are also documented.
If anyone still has an issue, feel free to create a new issue.
This might be related to: https://github.com/webpack/webpack-dev-server/issues/324 The solution posted in that other issue solved my problem.
Those using Polling
, watch for RAM use...
I used Intellij 2016.2.3 on Win1 and I've also solved the problem with ctrl + s.
Also experienced this problem with webpack-hot-middleware
on my own express-server.
Adding watchOptions
to my webpack-dev-middleware
-options solved this for me.
relevant part of my server.js:
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: webpackConfig.output.publicPath,
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
}));
@dryoma Thank You!! I removed () from the folder name, and live reloading works :)
@wmira Save my life
@awesomund works for me. Vue Cli webpack, Laravel Homestead, Win10,
Crazy this issue has been closed a year ago, tons of people on many machines still have it, and no solution by authors. On osx and have the same problem.
I know one could say "it's open source you should fix it"
There is not really a clear issue here, various people have posted their various issues here. If you still have a problem with reloading, please create a new issue and fill in all details. Locking this thread.
From the docs it says:
It binds a small express server on localhost:8080 which serves your static assets as well as the bundle (compiled automatically). It automatically updates the browser page when a bundle is recompiled (socket.io). Open http://localhost:8080/webpack-dev-server/bundle in your browser.
However if I run it this doesn't happen: I just get the following, but when I go to the serving URL I still have my old code.