pugkit 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/build.mjs +2 -2
- package/cli/index.mjs +11 -8
- package/config/main.mjs +4 -1
- package/index.mjs +2 -2
- package/package.json +1 -1
package/cli/build.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import { createBuilder } from '../index.mjs'
|
|
|
2
2
|
import { logger } from './logger.mjs'
|
|
3
3
|
|
|
4
4
|
export async function build(options = {}) {
|
|
5
|
-
const { root = process.cwd() } = options
|
|
5
|
+
const { root = process.cwd(), siteUrl } = options
|
|
6
6
|
|
|
7
7
|
logger.info('pugkit', 'building...')
|
|
8
8
|
|
|
9
9
|
const startTime = Date.now()
|
|
10
|
-
const builder = await createBuilder(root, 'production')
|
|
10
|
+
const builder = await createBuilder(root, 'production', { siteUrl })
|
|
11
11
|
await builder.build()
|
|
12
12
|
|
|
13
13
|
const elapsed = Date.now() - startTime
|
package/cli/index.mjs
CHANGED
|
@@ -33,14 +33,17 @@ cli
|
|
|
33
33
|
}
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
cli
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
cli
|
|
37
|
+
.command('build [root]', 'Production build')
|
|
38
|
+
.option('--site-url <url>', 'Override siteUrl in config')
|
|
39
|
+
.action(async (root, options) => {
|
|
40
|
+
try {
|
|
41
|
+
await build({ root: root || process.cwd(), siteUrl: options.siteUrl })
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error(err)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
44
47
|
|
|
45
48
|
cli.command('sprite [root]', 'Generate SVG sprite').action(async root => {
|
|
46
49
|
try {
|
package/config/main.mjs
CHANGED
|
@@ -75,10 +75,13 @@ function validateConfig(config) {
|
|
|
75
75
|
return config
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
export async function loadConfig(root = process.cwd()) {
|
|
78
|
+
export async function loadConfig(root = process.cwd(), inlineConfig = {}) {
|
|
79
79
|
const userConfig = await loadUserConfig(root)
|
|
80
80
|
const config = mergeConfig(defaultConfig, userConfig)
|
|
81
81
|
config.root = root
|
|
82
|
+
if (inlineConfig.siteUrl !== undefined && inlineConfig.siteUrl !== null) {
|
|
83
|
+
config.siteUrl = inlineConfig.siteUrl
|
|
84
|
+
}
|
|
82
85
|
validateConfig(config)
|
|
83
86
|
return config
|
|
84
87
|
}
|
package/index.mjs
CHANGED
|
@@ -10,8 +10,8 @@ import spriteTask from './tasks/svg-sprite.mjs'
|
|
|
10
10
|
import serverTask from './core/server.mjs'
|
|
11
11
|
import watcherTask from './core/watcher.mjs'
|
|
12
12
|
|
|
13
|
-
export async function createBuilder(root = process.cwd(), mode = 'development') {
|
|
14
|
-
const config = await loadConfig(root)
|
|
13
|
+
export async function createBuilder(root = process.cwd(), mode = 'development', inlineConfig = {}) {
|
|
14
|
+
const config = await loadConfig(root, inlineConfig)
|
|
15
15
|
const builder = new Builder(config, mode)
|
|
16
16
|
|
|
17
17
|
builder.registerTasks({
|