Skip to content

Commit 9f64baf

Browse files
committed
add init
0 parents  commit 9f64baf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1450
-0
lines changed

.babelrc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
// 此项指明,转码的规则
3+
"presets": [
4+
// env项是借助插件babel-preset-env,下面这个配置说的是babel对es6,es7,es8进行转码,并且设置amd,commonjs这样的模块化文件,不进行转码
5+
[
6+
"env",
7+
{
8+
"modules": false,
9+
"targets": {
10+
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
11+
}
12+
}
13+
// babel-preset-env 可以设置一些选项,这里就介绍几种,有兴趣自己去看英文文档
14+
// targets 指定运行环境
15+
// targets.node 指定node版本
16+
// targets.browsers 指定浏览器版本
17+
// modules 指定何种形式的模块,设置为false表示不转码模块
18+
],
19+
// 下面这个是不同阶段出现的es语法,包含不同的转码插件
20+
"stage-2"
21+
],
22+
// 下面这个选项是引用插件来处理代码的转换,transform-runtime用来处理全局函数和优化babel编译
23+
"plugins": [
24+
"lodash",
25+
"transform-vue-jsx",
26+
"transform-runtime",
27+
"transform-decorators-legacy"
28+
],
29+
// 下面指的是在生成的文件中,不产生注释
30+
"comments": false,
31+
// 下面这段是在特定的环境中所执行的转码规则,当环境变量是下面的test就会覆盖上面的设置
32+
"env": {
33+
// test 是提前设置的环境变量,如果没有设置BABEL_ENV则使用NODE_ENV,如果都没有设置默认就是development
34+
"test": {
35+
"presets": ["env", "stage-2"],
36+
// instanbul是一个用来测试转码后代码的工具
37+
38+
"plugins": [
39+
"istanbul",
40+
"transform-vue-jsx",
41+
"transform-decorators-legacy"
42+
]
43+
}
44+
}
45+
}

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/*.js
2+
config/*.js

.eslintrc.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// https://eslint.org/docs/user-guide/configuring
2+
3+
module.exports = {
4+
root: true,
5+
parser: "babel-eslint",
6+
parserOptions: {
7+
sourceType: "module"
8+
},
9+
env: {
10+
browser: true
11+
},
12+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
13+
extends: "standard",
14+
globals: {
15+
_: true
16+
},
17+
// required to lint *.vue files
18+
plugins: ["html", "vue"],
19+
// add your custom rules here
20+
rules: {
21+
// allow async-await
22+
"no-callback-literal": 0,
23+
"generator-star-spacing": "off",
24+
// allow debugger during development
25+
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
26+
// 默认配置always,要求在行末加上分号。
27+
semi: ["error", "always"],
28+
quotes: ["warn", "double"],
29+
"space-before-function-paren": 0,
30+
"prefer-promise-reject-errors": 0,
31+
"no-new": 0,
32+
"no-eval": 0
33+
}
34+
};

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
test/unit/coverage
8+
test/e2e/reports
9+
selenium-debug.log
10+
11+
# Editor directories and files
12+
.idea
13+
.vscode
14+
*.suo
15+
*.ntvs*
16+
*.njsproj
17+
*.sln

.postcssrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// https://github.com/michael-ciniawsky/postcss-load-config
2+
3+
module.exports = {
4+
"plugins": {
5+
// to edit target browsers: use "browserslist" field in package.json
6+
"autoprefixer": {}
7+
}
8+
}

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# vue-ts-scaffold
2+
3+
>
4+
5+
## 此脚手架工程以 https://github.com/ws456999/vue-typescript-starter 为基础库改进实现的
6+
7+
## 特性
8+
9+
* 一键式开关(使用 config.ts 控制是否使用 typescript)
10+
* 部分 loader 使用多线程加速
11+
* 基于 webpack 3.\*及 vue-cli 最新版本(2.9.3 生成的脚手架,进行相关性改进及性能优化。
12+
13+
## 开始
14+
15+
```bash
16+
# clone this repo
17+
git clone https://github.com/xiaofan9/vue-ts-scaffold
18+
19+
# Install project dependencies
20+
npm install
21+
22+
# serve with hot reload at localhost:8080
23+
npm run dev
24+
25+
# build for production with minification
26+
npm run build
27+
```

build/build.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"use strict";
2+
require("./check-versions")();
3+
4+
process.env.NODE_ENV = "production";
5+
6+
const ora = require("ora");
7+
const rm = require("rimraf");
8+
const path = require("path");
9+
const chalk = require("chalk");
10+
const webpack = require("webpack");
11+
const config = require("../config");
12+
const webpackConfig = require("./webpack.prod.conf");
13+
14+
const spinner = ora("building for production...");
15+
spinner.start();
16+
17+
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18+
if (err) throw err;
19+
webpack(webpackConfig, function(err, stats) {
20+
spinner.stop();
21+
if (err) throw err;
22+
process.stdout.write(
23+
stats.toString({
24+
colors: true,
25+
modules: false,
26+
children: false,
27+
chunks: false,
28+
chunkModules: false
29+
}) + "\n\n"
30+
);
31+
32+
if (stats.hasErrors()) {
33+
console.log(chalk.red(" Build failed with errors.\n"));
34+
process.exit(1);
35+
}
36+
37+
console.log(chalk.cyan(" Build complete.\n"));
38+
console.log(
39+
chalk.yellow(
40+
" Tip: built files are meant to be served over an HTTP server.\n" +
41+
" Opening index.html over file:// won't work.\n"
42+
)
43+
);
44+
});
45+
});

build/check-versions.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"use strict";
2+
const chalk = require("chalk");
3+
const semver = require("semver");
4+
const packageConfig = require("../package.json");
5+
const shell = require("shelljs");
6+
function exec(cmd) {
7+
return require("child_process")
8+
.execSync(cmd)
9+
.toString()
10+
.trim();
11+
}
12+
13+
const versionRequirements = [
14+
{
15+
name: "node",
16+
currentVersion: semver.clean(process.version),
17+
versionRequirement: packageConfig.engines.node
18+
}
19+
];
20+
21+
if (shell.which("npm")) {
22+
versionRequirements.push({
23+
name: "npm",
24+
currentVersion: exec("npm --version"),
25+
versionRequirement: packageConfig.engines.npm
26+
});
27+
}
28+
29+
module.exports = function() {
30+
const warnings = [];
31+
for (let i = 0; i < versionRequirements.length; i++) {
32+
const mod = versionRequirements[i];
33+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
34+
warnings.push(
35+
mod.name +
36+
": " +
37+
chalk.red(mod.currentVersion) +
38+
" should be " +
39+
chalk.green(mod.versionRequirement)
40+
);
41+
}
42+
}
43+
44+
if (warnings.length) {
45+
console.log("");
46+
console.log(
47+
chalk.yellow(
48+
"To use this template, you must update following to modules:"
49+
)
50+
);
51+
console.log();
52+
for (let i = 0; i < warnings.length; i++) {
53+
const warning = warnings[i];
54+
console.log(" " + warning);
55+
}
56+
console.log();
57+
process.exit(1);
58+
}
59+
};

build/logo.png

6.69 KB
Loading

0 commit comments

Comments
 (0)