Skip to content

Commit 1ca811d

Browse files
committed
feat: add res files to generate
1 parent 1f3a7af commit 1ca811d

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

build/generate.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const FROME = resolve('dist')
1111
const INDEXFILE = resolve('index.html')
1212
const CONFIGXML = resolve('config.xml')
1313
const TO = resolve('widget')
14+
const OtherFiles = ['res']
1415

1516

1617
function insertVendor() {
@@ -40,6 +41,9 @@ function copyFile() {
4041
let { source, dir } = getSource()
4142
dir.forEach(e => fs.mkdirSync(`${TO}${e}`))
4243
source.forEach(e => fs.copyFileSync(e.path, `${TO}${e.name}`))
44+
OtherFiles.forEach(e => {
45+
copyOtherFiles(e, 'widget')
46+
})
4347
fs.copyFileSync(CONFIGXML, `${TO}/config.xml`)
4448
fs.renameSync(`${TO}/dist`, `${TO}/html`)
4549
fs.writeFileSync(`${TO}/index.html`, fs.readFileSync(INDEXFILE).toString().replace(/url:[\S\s]*\/[\W\w]*\.html/, (match) => `${match.replace(/http:\/\/[\W\w]*:\d+\//, 'html/')}`))
@@ -64,8 +68,8 @@ function generate() {
6468
if(!fs.existsSync(FROME)){
6569
child_process.exec(`npm run build`, (error, stdout) => {
6670
if (error) {
67-
console.error(`exec error: ${error}`);
68-
return;
71+
console.error(`exec error: ${error}`)
72+
return
6973
}
7074
console.log(stdout)
7175
copyFile()
@@ -74,4 +78,17 @@ function generate() {
7478
copyFile()
7579
}
7680
}
81+
function copyOtherFiles(from, to) {
82+
let source = []
83+
let dir = []
84+
glob.sync(`${resolve(from)}/**`).forEach((pathname) => {
85+
if(fs.statSync( pathname ).isFile()){
86+
source.push({ path: pathname, name: pathname.replace(new RegExp(`[\\S\\s]*\/${from}`, 'g'), `/${from}`)})
87+
} else {
88+
dir.push(pathname.replace(new RegExp(`[\\S\\s]*\/${from}`, 'g'), `/${from}`))
89+
}
90+
})
91+
dir.forEach(e => fs.mkdirSync(`${resolve(to)}${e}`))
92+
source.forEach(e => fs.copyFileSync(e.path, `${resolve(to)}${e.name}`))
93+
}
7794
generate()
File renamed without changes.

static/.gitkeep

Whitespace-only changes.
File renamed without changes.

0 commit comments

Comments
 (0)