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

Support for sending non-HMR file change events to the client #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michaek
Copy link

@michaek michaek commented Jul 8, 2016

This is supporting the case of files modified by plugins (CopyWebpackPlugin, HtmlWebpackPlugin) that can't be sent via HMR because they're not required in a bundle. A simple case is documented here.

The config might look something like

if (config.devServer) {
    config.devServer.customWatch = {
        jade: 'src/**.jade'
    }
}

and it's assumed that sending the object key and changed file path to the client is sufficient to respond with something like

if (NODE_ENV === "development") {
    var webpackHotMiddlewareClient = require('webpack-hot-middleware/client')

    webpackHotMiddlewareClient.subscribe((e) => {
        if (e.type === 'jade') {
            window.location.reload()
        }
    })
}

The approach is currently naive (I've even left out the chokidar dependency!) I'm just hoping to start a discussion about solving a case that doesn't fit within HMR but nonetheless seems to cause a certain amount of headache.

@jrmcdona
Copy link

I am copying over some LESS files to my dist folder. Would be great if I can change my LESS and have HMR. Has anyone go that working??

@michaek
Copy link
Author

michaek commented Nov 21, 2017

@jrmcdona It's probably preferable to use the less loader and include your output CSS in the Webpack bundle. The approach described here would be best for files that can't be addressed as modules by loaders (and thus make use of hot module reloading).

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

Successfully merging this pull request may close these issues.

2 participants