{"action":"created","issue":{"url":"https://api.github.com/repos/kevlened/copy-webpack-plugin/issues/29","repository_url":"https://api.github.com/repos/kevlened/copy-webpack-plugin","labels_url":"https://api.github.com/repos/kevlened/copy-webpack-plugin/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/kevlened/copy-webpack-plugin/issues/29/comments","events_url":"https://api.github.com/repos/kevlened/copy-webpack-plugin/issues/29/events","html_url":"https://github.com/kevlened/copy-webpack-plugin/issues/29","id":141294450,"number":29,"title":"Does not copy files to actual output folder when webpack-dev-server is used","user":{"login":"af7","id":7850073,"avatar_url":"https://avatars.githubusercontent.com/u/7850073?v=3","gravatar_id":"","url":"https://api.github.com/users/af7","html_url":"https://github.com/af7","followers_url":"https://api.github.com/users/af7/followers","following_url":"https://api.github.com/users/af7/following{/other_user}","gists_url":"https://api.github.com/users/af7/gists{/gist_id}","starred_url":"https://api.github.com/users/af7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/af7/subscriptions","organizations_url":"https://api.github.com/users/af7/orgs","repos_url":"https://api.github.com/users/af7/repos","events_url":"https://api.github.com/users/af7/events{/privacy}","received_events_url":"https://api.github.com/users/af7/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-16T14:39:27Z","updated_at":"2016-04-05T17:04:17Z","closed_at":null,"body":"It appears that nothing happens when trying to copy some extra files (not bundled) to the output folder, under the `webpack-dev-server` logic:\r\n\r\n````\r\ndevServer: {\r\n            contentBase: './public',\r\n            outputPath: path.resolve(ROOT_PATH, 'public'),\r\n            historyApiFallback: true,\r\n            hot: true,\r\n            inline: true,\r\n            port: 33000,\r\n            progress: true\r\n        },\r\n        plugins: [\r\n            new CopyWebpackPlugin([\r\n                {from: 'src/css', to: 'css', force: true},\r\n                {from: 'src/img', to: 'img', force: true}\r\n            ]),\r\n            new webpack.HotModuleReplacementPlugin(),\r\n            new OpenBrowserPlugin({url: 'http://localhost:33000'})\r\n        ]\r\n````\r\n\r\nCan this be done somehow? The webpack-dev-server needs this to show some external CSS and IMAGE files. I used to be doing this with `gulp` but now I want to get rid of this dependency.\r\n\r\nUsing your plugin with the simple webpack (for `build`) works perfectly but not for `webpack-dev-server`.\r\n\r\nNOTE: I can achieve what I want if I use both `webpack` and `webpack-dev-server` on the `start` script, but this is not too elegant and done only for solving this problem:\r\n````\r\n  \"scripts\": {\r\n    \"build\": \"webpack\",\r\n    \"start\": \"npm run build && webpack-dev-server\"\r\n  },\r\n````\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/kevlened/copy-webpack-plugin/issues/comments/205897868","html_url":"https://github.com/kevlened/copy-webpack-plugin/issues/29#issuecomment-205897868","issue_url":"https://api.github.com/repos/kevlened/copy-webpack-plugin/issues/29","id":205897868,"user":{"login":"yntelectual","id":1354787,"avatar_url":"https://avatars.githubusercontent.com/u/1354787?v=3","gravatar_id":"","url":"https://api.github.com/users/yntelectual","html_url":"https://github.com/yntelectual","followers_url":"https://api.github.com/users/yntelectual/followers","following_url":"https://api.github.com/users/yntelectual/following{/other_user}","gists_url":"https://api.github.com/users/yntelectual/gists{/gist_id}","starred_url":"https://api.github.com/users/yntelectual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yntelectual/subscriptions","organizations_url":"https://api.github.com/users/yntelectual/orgs","repos_url":"https://api.github.com/users/yntelectual/repos","events_url":"https://api.github.com/users/yntelectual/events{/privacy}","received_events_url":"https://api.github.com/users/yntelectual/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T17:04:17Z","updated_at":"2016-04-05T17:04:17Z","body":"Hey, I have debugged the behaviour on windows and it seems to be a conflict in path handling between copy plugin and webpack's `compilation.assets`. \r\nThe tests also fail on windows with:\r\n```\r\napply function with file in from can use a glob to move multiple files to the root directory:\r\n\r\n      AssertionError: expected { Object (directory/directoryfile.txt, directory/nested/nestedfile.txt, ...) } to have keys 'file.txt', 'directory\\\\directoryfile.txt', and 'directory\\\\nested\\\\nestedfile.txt'\r\n      + expected - actual\r\n\r\n       [\r\n      -  \"directory/directoryfile.txt\"\r\n      -  \"directory/nested/nestedfile.txt\"\r\n      +  \"directory\\\\directoryfile.txt\"\r\n      +  \"directory\\\\nested\\\\nestedfile.txt\"\r\n         \"file.txt\"\r\n       ]\r\n```\r\n\r\nWebpack keys in `compilation.assets` are expected to contain forward slash `/` regardless of platform. However as copy plugin uses path normalization, it will store the copied assets with platform specific separator, which on windows happens to be `\\\\`.\r\n\r\nI am not sure, why it only causes problems when running `webpack-dev-server` though, as with regular `webpack` it does not pose problems.\r\n\r\nA dirty fix for the issue experienced by @Foxandxss is to force forward slashes in `compilation.assets` keys - change line  141 in `index.js` to:\r\n\r\n```javascript\r\nfunction writeFileToAssets(opts) {\r\n  var compilation = opts.compilation;\r\n  var relFileDest = opts.relFileDest;\r\n  var absFileSrc = opts.absFileSrc;\r\n  var forceWrite = opts.forceWrite;\r\n  var lastGlobalUpdate = opts.lastGlobalUpdate;\r\n  \r\n  //ensure forward slashes\r\n  relFileDest = relFileDest.replace(/\\\\/g, \"/\");\r\n\r\n```\r\nAfter that the dev server will see the copied assets and everything will work as expected.\r\nThis would require change in test cases however, otherwise it will report errors in many cases due to path normalization/separator mismatch.\r\n\r\n@kevlened do you think this would be ok? Or do you have any more info on how webpack handles keys in compilation.assets?\r\n\r\nIn case you are fine with the quick fix, i can submit a PR with the changes I have done locally.\r\n"}}