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

Fix #1394 for Windows support #1399

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion lib/css-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
normalize as nomalizePath,
sep as pathSep,
posix,
join as nodeJoin,
} from 'path';

import postcss from 'postcss';
Expand All @@ -30,6 +31,7 @@ import postCSSSimpleVars from 'postcss-simple-vars';
import cssNano from 'cssnano';
import camelCase from 'lodash.camelcase';
import glob from 'glob';
import { initialCssModule } from './initial-css-plugin';

const globP = promisify(glob);

Expand Down Expand Up @@ -152,7 +154,16 @@ export default function () {

if (!prefix) return;

const resolved = await this.resolve(id.slice(prefix.length), importer);
let resolved = null;
if (importer === initialCssModule) {
// Resolve the initial CSS differently
const cssPath = id.slice(prefix.length); // "shared/prerendered-app/path/to/file.css"
const absolutePath = nodeJoin(process.cwd(), 'src', cssPath); // absolute path
resolved = await this.resolve(absolutePath);
} else {
// Resolve normally
resolved = await this.resolve(id.slice(prefix.length), importer);
}
if (!resolved) throw Error(`Couldn't resolve ${id} from ${importer}`);

return prefix + resolved.id;
Expand Down
2 changes: 1 addition & 1 deletion lib/initial-css-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import glob from 'glob';
const globP = promisify(glob);

const moduleId = 'initial-css:';
const initialCssModule = '\0initialCss';
export const initialCssModule = '\0initialCss';

export default function initialCssPlugin() {
return {
Expand Down
Loading