[breaking change] rebuild style struct (#2021)
This commit is contained in:
@@ -6,15 +6,17 @@ const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const components = require('./get-components')();
|
||||
const dependencyTree = require('dependency-tree');
|
||||
const whiteList = ['info', 'icon', 'loading', 'cell', 'button'];
|
||||
const whiteList = ['info', 'icon', 'loading', 'cell', 'cell-group', 'button'];
|
||||
const dir = path.join(__dirname, '../es');
|
||||
|
||||
components.forEach(component => {
|
||||
const deps = analyzeDependencies(component);
|
||||
const deps = analyzeDependencies(component).map(dep =>
|
||||
getStyleRelativePath(component, dep)
|
||||
);
|
||||
const esEntry = path.join(dir, component, 'style/index.js');
|
||||
const libEntry = path.join(__dirname, '../lib', component, 'style/index.js');
|
||||
const esContent = deps.map(dep => `import '../../vant-css/${dep}.css';`).join('\n');
|
||||
const libContent = deps.map(dep => `require('../../vant-css/${dep}.css');`).join('\n');
|
||||
const esContent = deps.map(dep => `import '${dep}';`).join('\n');
|
||||
const libContent = deps.map(dep => `require('${dep}');`).join('\n');
|
||||
|
||||
fs.outputFileSync(esEntry, esContent);
|
||||
fs.outputFileSync(libEntry, libContent);
|
||||
@@ -45,17 +47,38 @@ function search(tree, component, checkList) {
|
||||
Object.keys(tree).forEach(key => {
|
||||
search(tree[key], component, checkList);
|
||||
components
|
||||
.filter(item => key.replace(dir, '').split('/').includes(item))
|
||||
.filter(item =>
|
||||
key
|
||||
.replace(dir, '')
|
||||
.split('/')
|
||||
.includes(item)
|
||||
)
|
||||
.forEach(item => {
|
||||
if (!checkList.includes(item) && !whiteList.includes(item) && item !== component) {
|
||||
if (
|
||||
!checkList.includes(item) &&
|
||||
!whiteList.includes(item) &&
|
||||
item !== component
|
||||
) {
|
||||
checkList.push(item);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function checkComponentHasStyle(component) {
|
||||
return fs.existsSync(
|
||||
path.join(__dirname, `../es/vant-css/`, `${component}.css`)
|
||||
function getStylePath(component) {
|
||||
if (component === 'base') {
|
||||
return path.join(__dirname, '../es/style/base.css');
|
||||
}
|
||||
return path.join(__dirname, `../es/${component}/index.css`);
|
||||
}
|
||||
|
||||
function getStyleRelativePath(component, style) {
|
||||
return path.relative(
|
||||
path.join(__dirname, `../es/${component}/style`),
|
||||
getStylePath(style)
|
||||
);
|
||||
}
|
||||
|
||||
function checkComponentHasStyle(component) {
|
||||
return fs.existsSync(getStylePath(component));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user