-
Notifications
You must be signed in to change notification settings - Fork 67
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
Dynamic asset prefix inside static pages #65
Dynamic asset prefix inside static pages #65
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested these changes in my app and in a test project too (with statically generated pages), everything worked as expected.
@megazazik Could you just convert tabs to spaces? I didn't touch that because else it'll show my name in git blame, but you did the job :) |
@arefaslani I thought I removed all tabs in the second commit. Are you sure there are tabs in the file still? I don't see them. |
@megazazik Ah sorry you're right. I was checking previous commit. |
@megazazik This is my configuration file: const withImages = require('next-images')
module.exports = withImages({
esModule: true,
assetPrefix: process.env.PUBLIC_URL,
dynamicAssetPrefix: true,
webpack(config, options) {
return config
}
}) I added this line in my hosts file to mimic CDN behavior:
I built the project using this command:
Then I started the project with this way and everything was fine:
But if I change the
It still shows the previous URL in chrome devtools. The URL that I used in build time. is this the expected behavior? Because I thought that you need to be able to change the asset prefix after build. Am I right? |
Is your page statically generated where you checked it? If it is then did you enabled static page revalidation? export async function getStaticProps() {
return {
props: {},
revalidate: 1,
}
} If you enabled it then after several refreshes your static pages will be re-generated with the new asset prefix values. If you are only using it in server-side rendered pages then asset prefix should be changed immediately when you start up the server and fire your first request. |
@peter-jozsa I neither used |
As far as I know statically generated pages are generated during |
This PR adds support of
dynamicAssetPrefix
in statically generated pages. See details here#63 (comment)