[build] fix build style entry in windows (#3558)

This commit is contained in:
neverland 2019-06-19 14:58:14 +08:00 committed by GitHub
parent 6d4bd79922
commit 3fa1a79065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,11 @@ const path = require('path');
const dependencyTree = require('dependency-tree'); const dependencyTree = require('dependency-tree');
const components = require('./get-components')(); const components = require('./get-components')();
// replace seq for windows
function replaceSeq(path) {
return path.split(path.sep).join('/');
}
const whiteList = [ const whiteList = [
'info', 'info',
'icon', 'icon',
@ -20,9 +25,9 @@ const whiteList = [
const dir = path.join(__dirname, '../es'); const dir = path.join(__dirname, '../es');
function destEntryFile(component, filename, ext = '') { function destEntryFile(component, filename, ext = '') {
const deps = analyzeDependencies(component).map(dep => ( const deps = analyzeDependencies(component).map(dep =>
getStyleRelativePath(component, dep, ext) getStyleRelativePath(component, dep, ext)
)); );
const esEntry = path.join(dir, component, `style/${filename}`); const esEntry = path.join(dir, component, `style/${filename}`);
const libEntry = path.join( const libEntry = path.join(
@ -63,12 +68,12 @@ function search(tree, component, checkList) {
Object.keys(tree).forEach(key => { Object.keys(tree).forEach(key => {
search(tree[key], component, checkList); search(tree[key], component, checkList);
components components
.filter(item => ( .filter(item =>
key key
.replace(dir, '') .replace(dir, '')
.split('/') .split('/')
.includes(item) .includes(item)
)) )
.forEach(item => { .forEach(item => {
if ( if (
!checkList.includes(item) && !checkList.includes(item) &&
@ -85,13 +90,16 @@ function getStylePath(component, ext = '.css') {
if (component === 'base') { if (component === 'base') {
return path.join(__dirname, `../es/style/base${ext}`); return path.join(__dirname, `../es/style/base${ext}`);
} }
return path.join(__dirname, `../es/${component}/index${ext}`); return path.join(__dirname, `../es/${component}/index${ext}`);
} }
function getStyleRelativePath(component, style, ext) { function getStyleRelativePath(component, style, ext) {
return path.relative( return replaceSeq(
path.join(__dirname, `../es/${component}/style`), path.relative(
getStylePath(style, ext) path.join(__dirname, `../es/${component}/style`),
getStylePath(style, ext)
)
); );
} }