gajus / write-file-webpack-plugin

Forces webpack-dev-server to write bundle files to the file system.
Other
527 stars 54 forks source link

No file is saved #29

Open folmert opened 7 years ago

folmert commented 7 years ago

I don't get it how it's supposed to work.

I'v added write-file-webpack-plugin to my webpack.config.js:

var WriteFilePlugin = require('write-file-webpack-plugin');

and included it in plugins:

plugins: [
        new WriteFilePlugin({force: true}),
        new webpack.HotModuleReplacementPlugin(),
        ],

Also, I've set devServer's outputPath to be the same as output.path as you recommended:

config.devServer = {
        host:        'localhost',
        //hot: true, // adding back will break webpack-dev-server!
        //port:        8080,
        port:        8080,
        inline:      true,
        stats:       '_errors-only',
        contentBase: './',
        outputPath: './app/dist/js/' // needed?
    };

    config.output = {
        path: './app/dist/js/' // needed?
        };

For the sake of test, I've deleted my previously generated bundle.js and run webpack-dev-server. Output:

C:\sites\YDR\branches\refactoring\development>webpack-dev-server
[11:27:38] [write-file-webpack-plugin] options { exitOnErrors: true,
  force: true,
  log: true,
  test: null,
  useHashIndex: true }
 http://localhost:8080/
webpack result is served from /
content is served from ./
(... typical dev-server output ...)

But no bundle.js is created anywhere.

adiachenko commented 7 years ago

I suspect it's an issue with resolving path. You bundle may have been created elsewhere. Check every directory up the chain from the path specified including the root of C: drive.

jereckley commented 7 years ago

I'm having the same issue... My issue is specific in that if I undo a change and save (so I already saved once in that state and undo to return to that state after saving in a different state) webpack is trying to refer me to the previous version that I just removed(because i'm deleting before rewriting). It's crazy... webpack remembers that it just wrote that same file and instead of rewriting just changes itself to refer back to the previous version.

I just question what force is supposed to do? It's defiantly not forcing a new write in that situation.