Skip to content

Commit 8162c09

Browse files
committed
feat: pri build -p "somePath" to rewrite publicPath
1 parent 2db01b6 commit 8162c09

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pri",
3-
"version": "0.7.47",
3+
"version": "0.7.48",
44
"types": "src/node/index.ts",
55
"main": "built/node/index.js",
66
"scripts": {

src/built-in-plugins/command-build/index.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ import { getStaticHtmlPaths } from "./generate-static-html"
2121

2222
const projectRootPath = process.cwd()
2323

24-
export const CommandBuild = async (instance: typeof pri) => {
24+
export const CommandBuild = async (
25+
instance: typeof pri,
26+
opts?: {
27+
publicPath?: string
28+
}
29+
) => {
2530
const env = "prod"
2631
const projectConfig = getConfig(projectRootPath, env)
2732

@@ -55,6 +60,7 @@ export const CommandBuild = async (instance: typeof pri) => {
5560
projectRootPath,
5661
env,
5762
entryPath: result.entryPath,
63+
publicPath: opts.publicPath, // If unset, use config value.
5864
projectConfig,
5965
pipeConfig: config => {
6066
staticHtmlPaths.forEach(staticHtmlPath => {
@@ -121,10 +127,10 @@ export default async (instance: typeof pri) => {
121127

122128
instance.commands.registerCommand({
123129
name: "build",
130+
options: [["-c, --cloud", "Cloud build tag"], ["-p, --publicPath <pathname>", "rewrite publicPath"]],
124131
description: text.commander.build.description,
125-
options: [["-c, --cloud", "Cloud build tag"]],
126-
action: async () => {
127-
await CommandBuild(instance)
132+
action: async (options: any) => {
133+
await CommandBuild(instance, { publicPath: options.publicPath })
128134

129135
// For async register commander, process will be exit automatic.
130136
process.exit(0)

0 commit comments

Comments
 (0)