{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/1996","repository_url":"https://api.github.com/repos/webpack/webpack","labels_url":"https://api.github.com/repos/webpack/webpack/issues/1996/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/1996/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/1996/events","html_url":"https://github.com/webpack/webpack/issues/1996","id":131323871,"number":1996,"title":"webpack does not seem to use publicPath with dynamic requires","user":{"login":"jlchereau","id":2556751,"avatar_url":"https://avatars.githubusercontent.com/u/2556751?v=3","gravatar_id":"","url":"https://api.github.com/users/jlchereau","html_url":"https://github.com/jlchereau","followers_url":"https://api.github.com/users/jlchereau/followers","following_url":"https://api.github.com/users/jlchereau/following{/other_user}","gists_url":"https://api.github.com/users/jlchereau/gists{/gist_id}","starred_url":"https://api.github.com/users/jlchereau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlchereau/subscriptions","organizations_url":"https://api.github.com/users/jlchereau/orgs","repos_url":"https://api.github.com/users/jlchereau/repos","events_url":"https://api.github.com/users/jlchereau/events{/privacy}","received_events_url":"https://api.github.com/users/jlchereau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-04T11:53:59Z","updated_at":"2016-02-04T13:12:17Z","closed_at":null,"body":"My project structure is the following:\r\n\r\n```\r\nroot\r\n    js                // javascript sources\r\n    styles         // less styles\r\n    webapp      // application files \r\n        config\r\n        locales\r\n        models\r\n        public     // static files\r\n            assets   // webpack output directory\r\n        views\r\n```\r\n\r\nMy webpack.config.js is as follows\r\n\r\n```\r\nmodule.exports = {\r\n    context: path.join(__dirname, '/'),\r\n    devtool: 'source-map',\r\n    entry: {\r\n        init: './js/app.init.js',\r\n        ...\r\n    },\r\n    ...\r\n    output: {\r\n        path: path.join(__dirname, '/webapp/public/assets'),\r\n        publicPath: config.get('uris:webpack:root'),\r\n        filename: '[name].bundle.js',\r\n        chunkFilename: '[name].chunk.js'\r\n    },\r\n    ...\r\n}\r\n```\r\n\r\nThe important thing is ```config.get('uris:webpack:root')``` sets the public path depending on configuration:\r\n\r\n- in test and development, it is the main site. For example, ```publicPath: \"http://localhost\"```.\r\n- in production, it points to a CDN. For example, ```publicPath: \"https://cdn.example.com/assets\"```.\r\n\r\nAll entries are properly generated and pulled according to configuration, using the absolute path defined in publicPath, that is the CDN in production.. \r\n\r\nThe issue is with the chunks generated from require statements in the code.\r\n\r\n```\r\nvar loader = require('bundle?name=[name]!./cultures/app.culture.' + locale + '.js');\r\nloader(setLocale);\r\n```\r\n\r\ncreates ```./webapp/public/assets/app.culture.en.chunk.js``` as expected but the require statement ignores publicPath and pulls the file from a relative path. Despite designating the CDN in the public path, the file is pulled from the web site.\r\n\r\nSame with:\r\n\r\n```\r\nloader = require('../styles/app.theme.' + oldTheme + '.less');\r\nloader(function (style) {\r\n    style.unuse();\r\n});\r\n```\r\n\r\nIs this an issue with webpack or is there a way to fix this?\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/179824763","html_url":"https://github.com/webpack/webpack/issues/1996#issuecomment-179824763","issue_url":"https://api.github.com/repos/webpack/webpack/issues/1996","id":179824763,"user":{"login":"jlchereau","id":2556751,"avatar_url":"https://avatars.githubusercontent.com/u/2556751?v=3","gravatar_id":"","url":"https://api.github.com/users/jlchereau","html_url":"https://github.com/jlchereau","followers_url":"https://api.github.com/users/jlchereau/followers","following_url":"https://api.github.com/users/jlchereau/following{/other_user}","gists_url":"https://api.github.com/users/jlchereau/gists{/gist_id}","starred_url":"https://api.github.com/users/jlchereau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlchereau/subscriptions","organizations_url":"https://api.github.com/users/jlchereau/orgs","repos_url":"https://api.github.com/users/jlchereau/repos","events_url":"https://api.github.com/users/jlchereau/events{/privacy}","received_events_url":"https://api.github.com/users/jlchereau/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T13:12:17Z","updated_at":"2016-02-04T13:12:17Z","body":"After further investigation, ```__webpack_require__.p = \"\";```\r\n\r\n![image](https://cloud.githubusercontent.com/assets/2556751/12815816/aa2c76a6-cb40-11e5-8baa-dee72abca27d.png)"}}