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

Add support for custom CSS file in workspace #659

Merged
merged 5 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions app/lib/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ Router.prototype.webRoutes = function () {
directory: path.join(process.cwd(), 'workspace')
})(req, res, (err) => {
if (err) {
// We treat this route as a special case, because index.html
// will always try to load it. If the user has created the
// file in their workspace directory, we'll serve it. If not,
// we don't want to return a 404 for it. We simply return a
// blank CSS file.
if (req.url === '/public/custom.css') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is needed @eduardoboucas. Don't we just need a blank custom.css in the public folder - that way if they're running from a direct download vs npm the solution still works?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You’re right, that’s a very good point!

res.header('Content-Type', 'text/css')

return res.end()
}

restify.plugins.serveStatic({
directory: path.resolve(__dirname, '../../..')
})(req, res, next)
Expand Down
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="/public/main.css">
<link rel="stylesheet" type="text/css" href="/public/custom.css">
<link rel="icon" type="image/png" href="/public/images/favicon.png">
</head>
<body>
Expand Down