olahol / reactpack

:package: build your react apps with one command and one `npm i`.
982 stars 36 forks source link

Add option to not inject bundle script #18

Closed stursby closed 8 years ago

stursby commented 8 years ago

So I ran into an issue using reactpack with react-router where bundle.js couldn't be loaded on nested routes because it was injected as a relative path. Setting inject: false in config.js and manually including bundle.js in my index.ejs template allows it to work on all routes. For example:

Here's my updated config.js:

config.plugins.push(new HtmlWebpackPlugin({
      title: 'Reactpack App',
      dev: options.dev,
      port: options.port,
      template: template,
      inject: false    
}))

And my index.ejs:

<script src="/bundle.js"></script>

So maybe adding an option/flag like --no-inject ?

Let me know your thoughts.

erikhuisman commented 8 years ago

Or add output.publicPath = '/' to the webpack config

olahol commented 8 years ago

In version 0.6.0 I have added the options --no-inject and --absolute-path to the cli, which should work for your case. Also the dev server now uses absolute paths by default. Thank you both @erikhuisman and @stursby.