Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using react router breaks the app #228

Closed
rukshn opened this issue May 25, 2016 · 4 comments
Closed

Using react router breaks the app #228

rukshn opened this issue May 25, 2016 · 4 comments

Comments

@rukshn
Copy link

rukshn commented May 25, 2016

Hi, I'm using react router together with this yeoman generator. So when using a react router with multiple nester routers such as this,

<Route path="/story/:sid" component={StoryComponent} />

I get the following error when a URL such as this '/story/1' is loaded on the browser.

http://localhost:8000/story/assets/app.js 404 (Not Found)

I guess the problem is here,

Changing this at index.html

<script type="text/javascript" src="./assets/app.js"></script>

To

<script type="text/javascript" src="/assets/app.js"></script>

Seems to fix the problem. So what should we do about this?

@weblogixx
Copy link
Member

Hi @rukshn,

thank you for your feedback. This is a known problem. We changed the url to relative to make the output work correctly in subdirectories. Unfortunately this clashes with react router. We will revert the setting back to absolute mode (as you have suggested, too) in a next patch version.

@rukshn
Copy link
Author

rukshn commented May 25, 2016

Hi @weblogixx if it's a known issue then it's fine I guess. Another thing I noted is that it also breaks hot reloading. Getting the following warning at console.

[HMR] Cannot find update. Need to do a full reload!
only-dev-server.js?2f87:28 
[HMR] (Probably because of restarting the webpack-dev-server)

@weblogixx
Copy link
Member

Hi @rukshn,

this is related to the same error :(. Please remove the "." in cfg/base.js:

module.exports = {
  additionalPaths: additionalPaths,
  port: defaultSettings.port,
  debug: true,
  devtool: 'eval',
  output: {
    path: path.join(__dirname, '/../dist/assets'),
    filename: 'app.js',
    publicPath: `.${defaultSettings.publicPath}` // <- Remove the leading dot!
  },

Hope this helps.

weblogixx added a commit to react-webpack-generators/react-webpack-template that referenced this issue May 27, 2016
…act-webpack-generators/generator-react-webpack#228)

Updated package dev dependencies to latest stable (karma-coverage, karma-mocha)
Updated karma.conf.js to set test env automatically, adjusted run port to match default webpack port (8000 instead 8080)
@weblogixx
Copy link
Member

Hi @rukshn,

this was fixed with react-webpack-template@1.7.0. After upgrading your generators dependencies (npm update -g with global install), new projects will have this back as default.

Thanks again for your input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants