!28 迁移 build.* 构建脚本到 script 目录下
Merge pull request !28 from Sight/develop
This commit is contained in:
commit
cf741e66c3
@ -1,26 +0,0 @@
|
|||||||
var fs = require('fs');
|
|
||||||
var { resolve } = require('path');
|
|
||||||
|
|
||||||
const inputDir = resolve(__dirname, './src/component')
|
|
||||||
|
|
||||||
const inputsArray = fs.readdirSync(inputDir).filter((name) => {
|
|
||||||
const componentDir = resolve(inputDir, name);
|
|
||||||
const isDir = fs.lstatSync(componentDir).isDirectory();
|
|
||||||
return isDir && fs.readdirSync(componentDir).includes('index.ts');
|
|
||||||
});
|
|
||||||
|
|
||||||
var content = fs.readFileSync("./src/theme/variable.less").toString() + '\n\n';
|
|
||||||
content += fs.readFileSync("./src/theme/index.less").toString() + '\n\n';
|
|
||||||
|
|
||||||
inputsArray.forEach(function (f) {
|
|
||||||
var path = "./src/component/" + f + "/index.less";
|
|
||||||
fs.exists(path,function(exists){
|
|
||||||
if(exists){
|
|
||||||
var c = fs.readFileSync(path);
|
|
||||||
content += c.toString() + '\n\n';
|
|
||||||
// @ts-ignore
|
|
||||||
content = content.replaceAll(/\@import.*?\;/g,"");
|
|
||||||
fs.writeFileSync('./lib/index.less',content);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
@ -23,9 +23,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite example",
|
"dev": "vite example",
|
||||||
"build": "npm run build:all && npm run build:es && npm run build:less && npm run build:types && npm run build:example",
|
"build": "npm run build:all && npm run build:es && npm run build:less && npm run build:types && npm run build:example",
|
||||||
"build:es": "vite build --emptyOutDir --config ./build.es.ts",
|
"build:es": "vite build --emptyOutDir --config ./script/build.es.ts",
|
||||||
"build:all": "vite build --emptyOutDir --config ./build.all.ts",
|
"build:all": "vite build --emptyOutDir --config ./script/build.all.ts",
|
||||||
"build:less": "node build.less.ts",
|
"build:less": "node ./script/build.less.ts",
|
||||||
"build:types": "rimraf types && tsc -d",
|
"build:types": "rimraf types && tsc -d",
|
||||||
"build:example": "vite build example",
|
"build:example": "vite build example",
|
||||||
"lint:eslint": "eslint 'src/**/*.{vue,ts,tsx}' --fix",
|
"lint:eslint": "eslint 'src/**/*.{vue,ts,tsx}' --fix",
|
||||||
@ -99,4 +99,4 @@
|
|||||||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ export default (): UserConfigExport => {
|
|||||||
alias: [
|
alias: [
|
||||||
{
|
{
|
||||||
find: '@',
|
find: '@',
|
||||||
replacement: resolve(__dirname, './')
|
replacement: resolve(process.cwd(), './')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -21,7 +21,7 @@ export default (): UserConfigExport => {
|
|||||||
outDir: 'lib',
|
outDir: 'lib',
|
||||||
emptyOutDir: true,
|
emptyOutDir: true,
|
||||||
lib: {
|
lib: {
|
||||||
entry: resolve(__dirname, './src/index.ts'),
|
entry: resolve(process.cwd(), './src/index.ts'),
|
||||||
name: 'layui-vue',
|
name: 'layui-vue',
|
||||||
formats: ['es'],
|
formats: ['es'],
|
||||||
fileName: (name) => `index.js`
|
fileName: (name) => `index.js`
|
@ -3,7 +3,7 @@ import vue from '@vitejs/plugin-vue'
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
|
||||||
const inputDir = resolve(__dirname, './src/component')
|
const inputDir = resolve(process.cwd(), './src/component')
|
||||||
|
|
||||||
const inputsArray = fs.readdirSync(inputDir).filter((name) => {
|
const inputsArray = fs.readdirSync(inputDir).filter((name) => {
|
||||||
const componentDir = resolve(inputDir, name)
|
const componentDir = resolve(inputDir, name)
|
||||||
@ -12,11 +12,11 @@ const inputsArray = fs.readdirSync(inputDir).filter((name) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const inputs = inputsArray.reduce((backObj, pkgName) => {
|
const inputs = inputsArray.reduce((backObj, pkgName) => {
|
||||||
backObj[pkgName] = resolve(__dirname, `./src/component/${pkgName}/index.ts`)
|
backObj[pkgName] = resolve(process.cwd(), `./src/component/${pkgName}/index.ts`)
|
||||||
return backObj
|
return backObj
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
inputs['index'] = resolve(__dirname, './src/index.ts')
|
inputs['index'] = resolve(process.cwd(), './src/index.ts')
|
||||||
|
|
||||||
export default (): UserConfigExport => {
|
export default (): UserConfigExport => {
|
||||||
return {
|
return {
|
||||||
@ -25,7 +25,7 @@ export default (): UserConfigExport => {
|
|||||||
alias: [
|
alias: [
|
||||||
{
|
{
|
||||||
find: '@',
|
find: '@',
|
||||||
replacement: resolve(__dirname, './')
|
replacement: resolve(process.cwd(), './')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
32
script/build.less.ts
Normal file
32
script/build.less.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* merge less file
|
||||||
|
* <p>
|
||||||
|
*/
|
||||||
|
var fs = require('fs');
|
||||||
|
var { resolve } = require('path');
|
||||||
|
|
||||||
|
const inputDir = resolve(process.cwd(), './src/component')
|
||||||
|
|
||||||
|
const inputsArray = fs.readdirSync(inputDir).filter((name) => {
|
||||||
|
const componentDir = resolve(inputDir, name)
|
||||||
|
const isDir = fs.lstatSync(componentDir).isDirectory()
|
||||||
|
return isDir && fs.readdirSync(componentDir).includes('index.ts')
|
||||||
|
})
|
||||||
|
|
||||||
|
// 读取基础变量 与 公共样式
|
||||||
|
var content = fs.readFileSync("./src/theme/variable.less").toString() + '\n\n';
|
||||||
|
content += fs.readFileSync("./src/theme/index.less").toString() + '\n\n';
|
||||||
|
|
||||||
|
// 组件样式
|
||||||
|
inputsArray.forEach(function (f) {
|
||||||
|
var path = "./src/component/" + f + "/index.less";
|
||||||
|
fs.exists(path, function (exists) {
|
||||||
|
if (exists) {
|
||||||
|
var c = fs.readFileSync(path);
|
||||||
|
content += c.toString() + '\n\n';
|
||||||
|
// @ts-ignore
|
||||||
|
content = content.replaceAll(/\@import.*?\;/g, "");
|
||||||
|
fs.writeFileSync('./lib/index.less', content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user