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

adds baseUrl to web_modules imports #480

Merged
merged 1 commit into from Jun 11, 2020
Merged

adds baseUrl to web_modules imports #480

merged 1 commit into from Jun 11, 2020

Conversation

danprince
Copy link
Contributor

@danprince danprince commented Jun 11, 2020

Following on from #474 (comment) and #476. Fixes #448.

This PR prepends the config.buildOptions.baseUrl to imports for web_modules so that they can be hosted at the same level as the rest of your site, rather than having to live at the domain root.

@danprince danprince requested a review from a team as a code owner June 11, 2020 16:35
@drwpow drwpow self-requested a review June 11, 2020 17:23
@@ -315,7 +315,8 @@ export async function command(commandOptions: CommandOptions) {
return spec;
}
if (dependencyImportMap.imports[spec]) {
let resolvedImport = path.posix.resolve(
let resolvedImport = path.posix.join(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems fine to me. Not sure why we were using resolve() before, since we seem to just be concatening, not resolving its on-disk location.

// web_modules imports should be rewritten to add baseUrl
const outputJS = fs.readFileSync(path.resolve(__dirname, 'build', '_dist_', 'index.js'), 'utf8');

expect(outputJS).toContain('/static/web_modules/array-flatten.js');
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

Awesome! Nice test addition.

@drwpow drwpow merged commit 859590f into FredKSchott:master Jun 11, 2020
@danprince danprince deleted the web-modules-baseurl branch June 11, 2020 17:31
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

Successfully merging this pull request may close these issues.

homepage option doesn't affect web_modules paths
2 participants