Skip to content

Commit

Permalink
fix: error
Browse files Browse the repository at this point in the history
  • Loading branch information
callqh committed Jul 19, 2024
1 parent b0920f4 commit 519597d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/toolkit/src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ pub fn codegen_html_document(document: &Document, minify: bool) -> String {
html_writer,
CodegenConfig {
minify,
quotes: Some(true),
..Default::default()
},
);

html_gen.emit(document).unwrap();

html_code
}

Expand Down
5 changes: 5 additions & 0 deletions examples/vite-adapter-react/farm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export default defineConfig({
],
compilation:{
persistentCache: false,
minify: false,
output: {
publicPath: '/a',
targetEnv: 'browser',
}
},
vitePlugins: [
Pages({
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config/normalize-config/normalize-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function tryGetDefaultPublicPath(
if (!targetEnv) {
return publicPath;
}
console.log('🤖 == publicPath:', publicPath);

if (publicPath) {
if (urlRegex.test(publicPath)) {
Expand Down Expand Up @@ -250,6 +251,7 @@ export function normalizePublicPath(
logger.warn(
` (!) Irregular 'publicPath' options: '${publicPath}', it should only be an absolute path like '/publicPath/', './', an url or an empty string.`
);
console.log('🤖 == defaultPublicPath:', defaultPublicPath);

return defaultPublicPath;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/plugin/js/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,16 @@ export function transformResourceInfo2RollupResource(
type: 'chunk',
code: source,
name: resource.name,
fileName: resource.name,
map: undefined,
sourcemapFileName: null,
preliminaryFileName: resource.origin.value
} satisfies OutputChunk;
} else {
let source: string | Uint8Array = Uint8Array.from(resource.bytes);
if (resource.resourceType === 'html' || resource.resourceType === 'css') {
source = String.fromCharCode(...source);
source = Buffer.from(resource.bytes).toString('utf-8');
}

return {
fileName: resource.name,
name: resource.name,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/server/middlewares/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export function staticMiddleware(devServerContext: Server): Middleware {

return async (ctx: Context, next: Next) => {
const requestPath = ctx.request?.path;
console.log('🤖 == return == requestPath:', requestPath);

if (requestPath && requestPath.startsWith(config.output.publicPath)) {
const modifiedPath = requestPath.substring(
config.output.publicPath.length
);
console.log('🤖 == return == modifiedPath:', modifiedPath);

ctx.request.path = `/${modifiedPath}`;

Expand Down

0 comments on commit 519597d

Please sign in to comment.