UNPKG

@cisdi/pangu

Version:

develop tool for ui-engine project

87 lines (66 loc) 1.81 kB
const path = require('path') const fs = require('fs') // working directory const workDir = process.cwd() // source directory const srcDir = path.resolve(workDir, 'src') // mock directory const mockDir = path.resolve(workDir, 'mocks') // public assets dir const publicDir = path.resolve(srcDir, 'public') // build output dir const outputDir = path.resolve(workDir, 'build') // package.json path const pkgPath = path.resolve(workDir, 'package.json') // app config path const appPath = path.resolve(workDir, 'app.json') // theme config path const themePath = path.resolve(workDir, 'theme.json') const themeCfgPath = path.resolve(workDir, 'theme.config.js') // template path let tpl = path.resolve(publicDir, 'index.ejs') // default const envPath = path.resolve(workDir, '.env') // 兼容 if (fs.existsSync(path.resolve(srcDir, 'index.ejs'))) { tpl = path.resolve(srcDir, 'index.ejs') } else if (fs.existsSync(path.resolve(publicDir, 'index.ejs'))) { tpl = path.resolve(publicDir, 'index.ejs') } const tplPath = tpl const publicPath = process.env.PUBLIC_PATH || '/' const tsConfigPath = path.resolve(workDir, 'tsconfig.json') const serverConfigPath = path.resolve(workDir, 'server.config.js') const entryFileNames = ['index', 'main'] const fileExtensions = ['tsx', 'ts', 'jsx', 'js'] const entryPaths = [] entryFileNames.forEach((fileName) => { fileExtensions.forEach((ext) => { entryPaths.push(path.resolve(srcDir, `${fileName}.${ext}`)) }) }) const watchPaths = [ themePath, themeCfgPath, appPath, tplPath, envPath, serverConfigPath, ] module.exports = { workDir, srcDir, pkgPath, appPath, tplPath, envPath, mockDir, themePath, publicDir, outputDir, publicPath, watchPaths, themeCfgPath, tsConfigPath, entryPaths, serverConfigPath, }