feat: auto generator cssfile (#368)

pull/376/head
cinwell.li 2016-10-13 12:05:43 +08:00 committed by FuryBean
parent 2bbd8d08a1
commit 8fda06a54c
2 changed files with 28 additions and 1 deletions

27
build/bin/gen-cssfile.js Normal file
View File

@ -0,0 +1,27 @@
var fs = require('fs');
var path = require('path');
var Components = require('../../components.json');
var THEMES = [
'theme-default'
];
var BASEPATH = path.resolve(__dirname, '../../packages/');
Components = Object.keys(Components);
function fileExists(filePath) {
try {
return fs.statSync(filePath).isFile();
} catch (err) {
return false;
}
};
THEMES.forEach(function(theme) {
Components.forEach(function(key) {
var fileName = key + '.css';
var filePath = path.resolve(BASEPATH, theme, 'src', fileName);
if (!fileExists(filePath)) {
fs.writeFileSync(filePath, '', 'utf8');
console.log(theme, ' 创建遗漏的 ', fileName, ' 文件');
}
});
});

View File

@ -13,7 +13,7 @@
"dev": "npm run bootstrap && npm run build:file && cooking watch -c build/cooking.demo.js -p",
"dist": "npm run clean && npm run build:file && npm run lint && cooking build -c build/cooking.conf.js,build/cooking.common.js,build/cooking.component.js -p && npm run build:utils && npm run build:theme",
"dist:all": "node build/bin/build-all.js && npm run build:theme",
"build:theme": "gulp build --gulpfile packages/theme-default/gulpfile.js && cp-cli packages/theme-default/lib lib/theme-default",
"build:theme": "node build/bin/gen-cssfile && gulp build --gulpfile packages/theme-default/gulpfile.js && cp-cli packages/theme-default/lib lib/theme-default",
"deploy": "npm run build:file && cooking build -c build/cooking.demo.js -p && echo element.eleme.io>>examples/element-ui/CNAME && gh-pages -d examples/element-ui --remote eleme && del examples/element-ui",
"bootstrap": "npm i && lerna bootstrap",
"pub": "sh build/release.sh",