javascript - Webpack Hot Module Reload specify different path to bundle -
i'm writing single page app @ moment , using webpack.
i want start using hot module replacement plugin because looks handy.
i have come in problem though. seems can't specify want bundle.js file be.
in index.html file, load bundle.js script following
<script type="text/javascript" src="/static/assets/script/app.bundle.js"></script>
once build complete, can deploy application server , everything's fine.
however, when use hot module replacement plugin, app.bundle.js on root of application. following works
<script type="text/javascript" src="/app.bundle.js"></script>
for production configuration, without hmr, have following :
// production entry: [ './src/project/scripts/entry.js' ], output: { path: path.join(__dirname, '/public/static/assets/script'), filename: 'app.bundle.js', },
and dev hmr, have following
entry: [ './src/project/scripts/entry.js', 'webpack/hot/dev-server', 'webpack-dev-server/client?http://localhost:8080/' ], output: { path: path.join(__dirname, '/public/static/assets/script'), filename: 'app.bundle.js' },
of course, when run dev, can't find app.bundle.js because path's pointing '/static/assets/script/app.bundle.js' in index.html.
is there way specify app.bundle.js going hmr plugin?
turns out there way. add path bundle.js in filename :
output: { path: __dirname + '/public', filename: 'static/assets/script/app.bundle.js' }