Giter Site home page Giter Site logo

Comments (13)

sokra avatar sokra commented on July 23, 2024 5

This should be possible within a plugin. Something similar to this:

plugins: [
  function(compiler) {
    compiler.plugin("after-compiler", function() {
      this.fileDependencies.push("/path/to/my/file");
      this.contextDependencies.push("/path/to/my/folder");
    }
  }
]

from webpack-dev-server.

kurtharriger avatar kurtharriger commented on July 23, 2024 3

I gave this a try and added this to the top of my gruntfile:

function WatchExternalFilesPlugin() {}
WatchExternalFilesPlugin.prototype.apply = function(compiler) {
  compiler.plugin("after-compile", function(compilation, callback) {
    compilation.fileDependencies.push("./app/worksheet.html");
    callback();
  });
};

When I change worksheet.html I see in the javascript console:

App updated. Recompiling... 
[WDS] App hot update... client?f5c9:52
[HMR] Checking for updates on the server... dev-server.js?05e4:41
GET http://localhost:8991/aa9359377b69ed42a399.hot-update.json 404 (Not Found) bootstrap aa9359377b69ed42a399?000c:23
[HMR] No Update found. 

If I comment out the HotModuleReplacementPlugin it will refresh the page otherwise it does nothing.

from webpack-dev-server.

Fridus avatar Fridus commented on July 23, 2024 2

Hi, try this : https://github.com/Fridus/webpack-watch-files-plugin ;)

from webpack-dev-server.

sap9433 avatar sap9433 commented on July 23, 2024 2

Just wrote a plugin that does exactly the same - solves your problem - https://www.npmjs.com/package/filewatcher-webpack-plugin .

@Fridus looks like this 1 got move power under its sleeve.

from webpack-dev-server.

jdeal avatar jdeal commented on July 23, 2024 1

Bit of a janky solution, but I used the text-loader module to do something like this. (In my case, CSS generated outside of webpack, but same principal.)

Basically, just npm install text-loader and then make a watch.js entry point (which you'll not actually use). In your watch.js file, add in text files like:

require('text!./app/worksheet.html');

That way, watch.js will get changed any time you change worksheet.html, and your app will get reloaded.

A better variant of this would be to have a "hash-loader" which would just MD5 hash the content and use that instead of the actual content, because in this case you don't actually need the content, just something to notify that there's a change. Should be pretty easy to create such a loader.

from webpack-dev-server.

tomek-he-him avatar tomek-he-him commented on July 23, 2024

+1 for this feature

from webpack-dev-server.

Ciantic avatar Ciantic commented on July 23, 2024

Is this possible or not?

from webpack-dev-server.

airwin avatar airwin commented on July 23, 2024

+1

from webpack-dev-server.

jaredleechn avatar jaredleechn commented on July 23, 2024

👏

from webpack-dev-server.

SpaceK33z avatar SpaceK33z commented on July 23, 2024

Closing issue because the answer provided is clear; make a loader for this, or use an existing one :).

from webpack-dev-server.

 avatar commented on July 23, 2024

Did anyone ever come up with a solution for this? It doesn't seem like fileDependencies or contextDependencies exist anywhere.

from webpack-dev-server.

dudewad avatar dudewad commented on July 23, 2024

@sokra shouldn't this be compiler.plugin('after-compile'...? I can't find any hooks anywhere called after-compiler.

from webpack-dev-server.

ivanm376 avatar ivanm376 commented on July 23, 2024

possible problem for Linux users see https://webpack.js.org/configuration/watch/#not-enough-watchers

from webpack-dev-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.