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

Don't assume the project is hosted at the root #94

Merged
merged 5 commits into from
Jul 24, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var nodeModulesPath = path.join(__dirname, '..', 'node_modules');
var indexHtmlPath = path.resolve(__dirname, relativePath, 'index.html');
var faviconPath = path.resolve(__dirname, relativePath, 'favicon.ico');
var buildPath = path.join(__dirname, isInNodeModules ? '../../..' : '..', 'build');
var publicPath = require(path.resolve(__dirname, relativePath, 'package.json')).homepage || '/';

module.exports = {
bail: true,
Expand All @@ -35,9 +36,7 @@ module.exports = {
path: buildPath,
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].chunk.js',
// TODO: this wouldn't work for e.g. GH Pages.
// Good news: we can infer it from package.json :-)
publicPath: '/'
publicPath: publicPath
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it’s best to infer just the path portion? e.g. stuff.com/wow should give us just /wow.
What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agreed - good call. Putting together a regex that could do it, but do you think there is a more elegant way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url.parse() gives you an object with pathname.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right. Thanks for bearing with me. Added that, so we should now always have the path portion of the url defined in homepage, or / if it isn't defined.

},
resolve: {
extensions: ['', '.js'],
Expand Down
17 changes: 17 additions & 0 deletions template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "my-app",
"version": "0.0.1",
"private": true,
"devDependencies": {
"react-scripts": "0.1.0"
},
"dependencies": {
"react": "^15.2.1",
"react-dom": "^15.2.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject"
}
}