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

feature: add static.prefix #2755

Merged
merged 2 commits into from Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/common/options.js
Expand Up @@ -299,7 +299,9 @@ Options.defaults = {
push: false,
shouldPush: null
},
static: {},
static: {
prefix: true
},
gzip: {
threshold: 0
},
Expand Down
10 changes: 5 additions & 5 deletions lib/core/renderer.js
Expand Up @@ -249,12 +249,12 @@ module.exports = class Renderer {
}

// For serving static/ files to /
this.useMiddleware(
serveStatic(
resolve(this.options.srcDir, 'static'),
this.options.render.static
)
const staticMiddleware = serveStatic(
resolve(this.options.srcDir, 'static'),
this.options.render.static
)
staticMiddleware.prefix = this.options.render.static.prefix
Copy link
Member

Choose a reason for hiding this comment

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

Code readability suggestion: Boolean(this.options.render.static.prefix).

Copy link
Member Author

Choose a reason for hiding this comment

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

It may make unexpected behavior, if not config static.prefix, it will be false and ignore the prefix, but prefix should not be ignored by default.

Copy link
Member

@pi0 pi0 Feb 4, 2018

Choose a reason for hiding this comment

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

So what if we add a default value true in https://github.com/nuxt/nuxt.js/blob/215832769edc42e7077e8db970fbcda3276ecf0a/lib/common/options.js#L308? This prefix is little confusing now. Because it doesn't means use this prefix string but means just use prefix 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

@pi0 Added the default value.

this.useMiddleware(staticMiddleware)

// Serve .nuxt/dist/ files only for production
// For dev they will be served with devMiddleware
Expand Down