Skip to content

Commit

Permalink
patch package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Oct 20, 2023
1 parent b974f2c commit 9013a79
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,33 @@ viteProcess.on('close', (code) => {

const socketIniPath = resolve(cwd, 'socket.ini')
const socketIni = readFileSync(socketIniPath, 'utf-8')
const modifiedSocketIni = socketIni.replace(
'copy = "src"',
'copy = "dist"'
)
const modifiedSocketIni = socketIni
.replace(
'copy = "src"',
'copy = "dist"'
)
.replace(
'; script = "npm run build"',
'script = "npm run build"'
)
writeFileSync(socketIniPath, modifiedSocketIni, 'utf8');

process.stdout.write('\nPatching index.html for the create-vite\n')

const indexHTMLPath = resolve(cwd, 'index.html')
const indexHTML = readFileSync(indexHTMLPath, 'utf-8')
const modifiedData = indexHTML.replace('<head>', '<head>\n' + CSP + '\n');

writeFileSync(indexHTMLPath, modifiedData, 'utf8');

process.stdout.write('\nPatching package.json\n')

const packageJSONPath = resolve(cwd, 'package.json')
const packageJSON = readFileSync(packageJSONPath, 'utf-8')
const modifiedPackageJSON = packageJSON.replace(
'"tsc && vite build"',
'"tsc && vite build --"'
)
writeFileSync(packageJSONPath, modifiedPackageJSON, 'utf8');

process.stdout.write(`\nDone!\n\nBuild and run your app with:\nssc build -r ${projectName}`)
})

0 comments on commit 9013a79

Please sign in to comment.