-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
luoxue
committed
Dec 9, 2019
1 parent
b1aa749
commit 6dd3812
Showing
36 changed files
with
910 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
console.log('--------eslint-------') | ||
module.exports = { | ||
root: true, | ||
env: { | ||
browser: true, | ||
node: true | ||
}, | ||
extends: [ | ||
'plugin:vue/essential', | ||
'eslint:recommended', | ||
'standard' | ||
], | ||
rules: { | ||
'no-new': 0, | ||
'max-len': 0, | ||
'space-before-function-paren': 0, | ||
'eslint-disable-next-line': 0, | ||
'no-useless-escape': 0 | ||
}, | ||
globals: { | ||
wx: true, | ||
window: true, | ||
document: true | ||
}, | ||
parserOptions: { | ||
parser: '@typescript-eslint/parser' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
/* | ||
* @description 编译器配置 | ||
* @param tabSize 默认tab为两个空格 | ||
* @param formatOnSave 保存时自动修复 | ||
*/ | ||
"editor.tabSize": 2, | ||
"editor.formatOnSave": true, | ||
/* | ||
* @description eslint 配置 | ||
* @param alwaysShowStatus 配置 | ||
* @param autoFixOnSave 保存时自动修复 | ||
* @param validate 在vue中添加错误提示 | ||
*/ | ||
"eslint.alwaysShowStatus": true, | ||
"eslint.autoFixOnSave": true, | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
{ | ||
"language": "vue", | ||
"autoFix": true | ||
} | ||
], | ||
/* | ||
* @description tslint 配置 | ||
* @param autoFixOnSave 保存时自动修复 | ||
* @param alwaysShowRuleFailuresAsWarnings 所有特征都是用 Warnings | ||
*/ | ||
"tslint.autoFixOnSave": true, | ||
"tslint.alwaysShowRuleFailuresAsWarnings": true, | ||
/* | ||
* @description stylelint 配置 | ||
* @param autoFixOnSave 保存时自动修复 | ||
*/ | ||
"stylelint.autoFixOnSave": true, | ||
/* | ||
* @description vetur 配置 | ||
*/ | ||
"vetur.format.defaultFormatter.html": "prettier", | ||
"vetur.format.defaultFormatterOptions": { | ||
"prettier": { | ||
"semi": false, | ||
"singleQuote": true | ||
} | ||
}, | ||
/* | ||
* @description 配置编辑器设置以覆盖某种语言 | ||
*/ | ||
"[typescript]": { | ||
// "editor.defaultFormatter": "esbenp.prettier-vscode" | ||
"editor.defaultFormatter": "eg2.tslint" | ||
}, | ||
"[html]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[jsonc]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[json]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[vue]": { | ||
"editor.defaultFormatter": "eg2.tslint" | ||
}, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
}, | ||
"[javascriptreact]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
#!/usr/bin/env node | ||
process.env.NODE_ENV = "none"; | ||
const commandsName = ["build", "dev", 'dll', 'build:ssr', 'ssr:server']; | ||
process.env.NODE_ENV = 'none' | ||
const commandsName = ['build', 'dev', 'dll', 'build:ssr', 'ssr:server', 'lint'] | ||
const { | ||
injectCommand, | ||
commandComplete, | ||
commandName | ||
} = require("../cli/CommandAPI"); | ||
commandName.push(...commandsName); | ||
} = require('../cli/CommandAPI') | ||
|
||
const PluginAPI = require('../cli/PluginAPI') | ||
commandName.push(...commandsName) | ||
|
||
commandsName.forEach(name => { | ||
const { command } = require(`../build/${name}`); | ||
command(injectCommand); | ||
}); | ||
const { command } = require(`../build/${name}`) | ||
command(injectCommand, PluginAPI) | ||
}) | ||
|
||
commandComplete(); | ||
commandComplete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
module.exports.command = function (injectCommand) { | ||
injectCommand(function({ program,cleanArgs, boxConfig }) { | ||
module.exports.command = function(injectCommand) { | ||
injectCommand(function({ program, cleanArgs, boxConfig }) { | ||
program | ||
.command("build [app-page]") | ||
.description(`构建生产环境`) | ||
.option("-r, --report", "打包分析报告") | ||
.option("-d, --dll", "合并差分包") | ||
.command('build [app-page]') | ||
.description('构建生产环境') | ||
.option('-r, --report', '打包分析报告') | ||
.option('-d, --dll', '合并差分包') | ||
.action(async (name, cmd) => { | ||
const options = cleanArgs(cmd); | ||
const args = Object.assign(options, { name }, boxConfig); | ||
process.env.NODE_ENV = "production"; | ||
const options = cleanArgs(cmd) | ||
const args = Object.assign(options, { name }, boxConfig) | ||
process.env.NODE_ENV = 'production' | ||
if (!name && boxConfig.pages) { | ||
args.clear = true; | ||
args.clear = true | ||
Object.keys(boxConfig.pages).forEach(page => { | ||
args.name = page; | ||
action(args); | ||
}); | ||
args.name = page | ||
action(args) | ||
}) | ||
} else { | ||
action(args); | ||
action(args) | ||
} | ||
}); | ||
}); | ||
}) | ||
}) | ||
} | ||
|
||
function action(options) { | ||
const rimraf = require("rimraf"); | ||
const ora = require("ora"); | ||
const chalk = require("chalk"); | ||
const path = require("path"); | ||
const rimraf = require('rimraf') | ||
const ora = require('ora') | ||
const chalk = require('chalk') | ||
const path = require('path') | ||
// 删除 dist 目录 | ||
options.clear && rimraf.sync(path.join(process.cwd(), "dist")); | ||
options.clear && rimraf.sync(path.join(process.cwd(), 'dist')) | ||
|
||
const config = require("./base")(options); | ||
const webpack = require("webpack"); | ||
const spinner = ora("开始构建项目..."); | ||
spinner.start(); | ||
const config = require('./base')(options) | ||
const webpack = require('webpack') | ||
const spinner = ora('开始构建项目...') | ||
spinner.start() | ||
|
||
if (typeof options.chainWebpack === "function") { | ||
options.chainWebpack(config); | ||
if (typeof options.chainWebpack === 'function') { | ||
options.chainWebpack(config) | ||
} | ||
|
||
webpack(config.toConfig(), function(err, stats) { | ||
spinner.stop(); | ||
if (err) throw err; | ||
spinner.stop() | ||
if (err) throw err | ||
process.stdout.write( | ||
stats.toString({ | ||
colors: true, | ||
modules: false, | ||
children: false, | ||
chunks: false, | ||
chunkModules: false | ||
}) + "\n\n" | ||
); | ||
}) + '\n\n' | ||
) | ||
|
||
if (stats.hasErrors()) { | ||
console.log(chalk.red("构建失败\n")); | ||
process.exit(1); | ||
console.log(chalk.red('构建失败\n')) | ||
process.exit(1) | ||
} | ||
console.log(chalk.cyan("build完成\n")); | ||
}); | ||
console.log(chalk.cyan('build完成\n')) | ||
}) | ||
} |
Oops, something went wrong.