初始化项目
This commit is contained in:
commit
4ab6cf96c0
38 files changed
+8362
No files matched your search
@@ -0,0 +1,50 @@
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const chalk = require('chalk');
|
||||
const webpack = require('webpack');
|
||||
const webpackDevServer = require('webpack-dev-server');
|
||||
const util = require('./util');
|
||||
const webpackConfig = require('./webpack.react');
|
||||
|
||||
let _paths = {};
|
||||
|
||||
let _configJson = {};
|
||||
|
||||
exports.init = (type, paths, command) => {
|
||||
_paths = paths;
|
||||
|
||||
let tplPath = path.join(_paths.rootPath, util.tplTypePath(type));
|
||||
fs.copy(tplPath, _paths.targetPath)
|
||||
.then(() => {
|
||||
console.log(chalk.bold.green('生成模板成功!'));
|
||||
|
||||
_configJson = util.configJson(_paths.targetPath);
|
||||
|
||||
if(_configJson.template == 'react') {
|
||||
webpackConfig.run(command);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
console.error(chalk.bold.red('生成模板失败!'));
|
||||
});
|
||||
}
|
||||
|
||||
exports.dev = (paths, command) => {
|
||||
_paths = paths;
|
||||
|
||||
if(_configJson.template == 'react') {
|
||||
webpackConfig.run(paths, command);
|
||||
}
|
||||
}
|
||||
|
||||
exports.pack = (paths, command) => {
|
||||
_paths = paths;
|
||||
|
||||
_configJson = util.configJson(_paths.targetPath);
|
||||
|
||||
if(_configJson.template == 'react') {
|
||||
webpackConfig.run(paths, command);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user