Skip to content

Commit ee8c83f

Browse files
committed
feat: change assetPrefix and default exported css filename
1 parent 023aa66 commit ee8c83f

File tree

5 files changed

+32
-29
lines changed

5 files changed

+32
-29
lines changed

packages/core/src/node/build.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
TEMP_ONCLICK_ATTR,
1717
TEMP_ONKEYPRESS_ATTR,
1818
TISTORY_TAG_IDENTIFIER,
19+
TISTORY_DEFAULT_XML_NAME,
1920
} from './constants';
2021
import { initRsbuild } from './initRsbuild';
2122
import { convertCdataObj } from './utils/convertXml';
@@ -86,7 +87,7 @@ export async function renderHtml(
8687
}
8788

8889
// Get the html generated by builder, as the default ssr template
89-
const htmlTemplatePath = join(outputPath, 'index.html');
90+
const htmlTemplatePath = join(outputPath, TISTORY_DEFAULT_XML_NAME);
9091
const htmlTemplate = await fs.readFile(htmlTemplatePath, 'utf-8');
9192

9293
let appHtml = '';
@@ -168,7 +169,7 @@ export async function bundleXml(appDirectory: string, config: UserConfig) {
168169
const options = { compact: true, ignoreComment: true, spaces: 4 };
169170
const result = js2xml(skinInfo, options);
170171

171-
const fileName = 'index.xml';
172+
const fileName = TISTORY_DEFAULT_XML_NAME;
172173
await fs.ensureDir(join(outputPath, dirname(fileName)));
173174
await fs.writeFile(join(outputPath, fileName), result);
174175

packages/core/src/node/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export const SSR_ENTRY = path.join(
3535
export const OUTPUT_DIR = 'build';
3636
export const BUNDLE_DIR = 'images';
3737

38+
export const TISTORY_DEFAULT_HTML_NAME = 'index.html';
39+
export const TISTORY_DEFAULT_XML_NAME = 'index.xml';
40+
export const TISTORY_DEFAULT_CSS_NAME = 'style.css';
41+
3842
export const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
3943
export const HEAD_MARKER = '<!--<?- HEAD ?>-->';
4044
export const META_GENERATOR = '<!--<?- GENERATOR ?>-->';

packages/core/src/node/initRsbuild.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
PUBLIC_DIR,
2121
DEFAULT_TITLE,
2222
BUNDLE_DIR,
23+
TISTORY_DEFAULT_CSS_NAME,
2324
} from './constants';
2425
import { initRouteService } from './route/init';
2526
import { rsbuildPluginDocVM } from './runtimeModule';
@@ -57,12 +58,11 @@ async function createInternalBuildConfig(
5758
const ssrOutDir = path.join(baseOutDir, 'ssr');
5859

5960
// const DEFAULT_THEME = require.resolve("@rspress/theme-default");
60-
const base = config?.base ?? '';
6161

6262
// In production, we need to add assetPrefix in asset path
6363
const assetPrefix = isProduction()
64-
? removeTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base)
65-
: '';
64+
? removeTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? '.')
65+
: '.';
6666
const reactVersion = await detectReactVersion();
6767

6868
const normalizeIcon = (icon: string | undefined) => {
@@ -148,27 +148,26 @@ async function createInternalBuildConfig(
148148
'process.env.TEST': JSON.stringify(process.env.TEST),
149149
},
150150
},
151-
performance: {
152-
chunkSplit: {
153-
override: {
154-
cacheGroups: {
155-
// extract all CSS into a single file
156-
// ensure CSS in async chunks can be loaded for SSG
157-
styles: {
158-
name: 'styles',
159-
minSize: 0,
160-
chunks: 'all',
161-
test: /\.(?:css|less|sass|scss)$/,
162-
priority: 99,
163-
},
164-
},
165-
},
166-
},
167-
},
151+
// performance: {
152+
// chunkSplit: {
153+
// override: {
154+
// cacheGroups: {
155+
// // extract all CSS into a single file
156+
// // ensure CSS in async chunks can be loaded for SSG
157+
// styles: {
158+
// filename: 'style.css',
159+
// minSize: 0,
160+
// chunks: 'all',
161+
// test: /\.(?:css|less|sass|scss)$/,
162+
// priority: 99,
163+
// },
164+
// },
165+
// },
166+
// },
167+
// },
168168
tools: {
169169
bundlerChain(chain, { target }) {
170170
const isServer = target === 'node';
171-
console.log('::', isServer);
172171

173172
if (isServer) {
174173
chain.output.filename('main.cjs');
@@ -194,6 +193,10 @@ async function createInternalBuildConfig(
194193
overrideBrowserslist: webBrowserslist,
195194
distPath: {
196195
root: csrOutDir,
196+
css: '.',
197+
},
198+
filename: {
199+
css: TISTORY_DEFAULT_CSS_NAME,
197200
},
198201
},
199202
},

packages/core/src/runtime/clientEntry.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import '@tistory-react/devtool/css';
99
export async function renderInBrowser() {
1010
const container = document.getElementById('root')!;
1111

12-
useRemoveTistoryTags();
13-
1412
const RootApp = () => {
13+
useRemoveTistoryTags();
1514
return (
1615
<BrowserRouter>
1716
<App />

packages/shared/src/types/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ export interface UserConfig {
2323
* The root directory of the site.
2424
*/
2525
root?: string;
26-
/**
27-
* Base path of the site.
28-
*/
29-
base?: string;
3026
/**
3127
* Path to html icon file.
3228
*/

0 commit comments

Comments
 (0)