Skip to content

Commit a156ac1

Browse files
author
weichen
committed
init
0 parents  commit a156ac1

Some content is hidden

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

60 files changed

+167643
-0
lines changed

.babelrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"targets": {
5+
"browsers": ["last 3 versions", "> 2%", "ie >= 9", "Firefox >= 30", "Chrome >= 30"]
6+
},
7+
"modules": false,
8+
"loose": true,
9+
"useBuiltIns": true
10+
}],
11+
"stage-2"
12+
],
13+
"plugins": [
14+
"transform-runtime"
15+
],
16+
"env": {
17+
"test": {
18+
"plugins": ["transform-es2015-modules-commonjs"]
19+
}
20+
},
21+
"ignore": [
22+
"libs/**/*.js"
23+
]
24+
}

.editorconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
# The JSON files contain newlines inconsistently
13+
[*.json]
14+
insert_final_newline = ignore
15+
16+
# Minified JavaScript files shouldn't be changed
17+
[**.min.js]
18+
indent_style = ignore
19+
insert_final_newline = ignore
20+
21+
[*.md]
22+
trim_trailing_whitespace = false
23+

.eslintignore

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

.eslintrc.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// http://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/feross/standard/blob/master/RULES.md#javascript-standard-style
13+
extends: 'standard',
14+
// required to lint *.vue files
15+
plugins: [
16+
'html'
17+
],
18+
// add your custom rules here
19+
'rules': {
20+
// allow paren-less arrow functions
21+
'arrow-parens': 0,
22+
'curly': ['error', 'all'],
23+
'indent': ['error', 2],
24+
'quotes': ['error', 'single'],
25+
'semi-spacing': ['error', { 'before': false, 'after': true }],
26+
'valid-typeof': 'error',
27+
// allow debugger during development
28+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
29+
'no-with': 1,
30+
'no-empty': 'error',
31+
'no-extra-semi': 'error',
32+
'no-empty-pattern': 'error',
33+
'no-native-reassign': 'error',
34+
'no-multi-spaces': 0,
35+
'spaced-comment': 0,
36+
'no-control-regex': 0,
37+
'prefer-promise-reject-errors': 0
38+
}
39+
}

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Mac.
2+
.DS_Store
3+
4+
# Node modules.
5+
node_modules/
6+
7+
# Dist.
8+
dist/
9+
10+
# Testfile.
11+
test/unit/coverage
12+
test/e2e/reports
13+
.coverage-report/
14+
15+
# Debug log.
16+
npm-debug.log
17+
selenium-debug.log
18+
19+
# IDEs.
20+
.idea/
21+
.vscode/
22+
23+
# Cache-Loader.
24+
.cache-loader/
25+
26+
# laya
27+
.laya

build/pre-loaders.conf.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const ecoDev = process.argv.includes('--eco-mode')
2+
3+
if (ecoDev) {
4+
console.log(`
5+
[EcoMode] 进入 EcoMode!
6+
===
7+
专为低配笔记本设计,节省您的电池电量!
8+
在外加班也不会电量血崩,腰不酸腿部疼一加就是十小时!
9+
10+
注:第一次生成 Cache 时会耗时较久,请耐心等待.
11+
`)
12+
}
13+
14+
module.exports = ecoDev
15+
? ['cache-loader']
16+
: ['cache-loader', 'thread-loader']

build/ts-error-hint-plugin.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const http = require('http')
2+
const socketIO = require('socket.io')
3+
4+
let port = 51357
5+
startServer()
6+
7+
module.exports = {
8+
setErrorMsg
9+
}
10+
11+
function startServer () {
12+
const httpServer = http.createServer(serverHandler)
13+
httpServer.on('error', function () {
14+
if (port < 51357 + 10) {
15+
port++
16+
startServer()
17+
}
18+
})
19+
20+
httpServer.listen(port, function (error) {
21+
console.info('[Info] MyErrorPlugin is on at port ' + port + '.')
22+
23+
const io = socketIO(httpServer)
24+
let errorMsg = ''
25+
26+
io.on('connection', socket => {
27+
setInterval(() => {
28+
const errorHTML = `
29+
<div>
30+
<h3 style="color: #caf1ff">出错了!</h3>
31+
<hr>
32+
<p style="color: #ff7c67">${errorMsg}</p>
33+
</div>
34+
`
35+
36+
errorMsg
37+
? socket.emit('onError', errorHTML)
38+
: socket.emit('noError', '')
39+
}, 2000)
40+
})
41+
})
42+
}
43+
44+
function setErrorMsg (msg, from) {
45+
errorMsg = msg
46+
}
47+
48+
function serverHandler (req, res) {
49+
res.setHeader('Access-Control-Allow-Origin', '*')
50+
res.setHeader('Access-Control-Request-Method', '*')
51+
res.setHeader('Access-Control-Allow-Methods', 'GET')
52+
res.setHeader('Access-Control-Allow-Headers', '*')
53+
54+
if (req.url === '/script') {
55+
res.writeHead(200, {
56+
'Content-Type': 'application/javascript; charset=utf-8'
57+
})
58+
59+
res.write(`
60+
var errorHTMLNode = document.createElement('div')
61+
errorHTMLNode.style.display = 'none'
62+
errorHTMLNode.style.width = '100%'
63+
errorHTMLNode.style.height = '100%'
64+
errorHTMLNode.style.position = 'fixed'
65+
errorHTMLNode.style.top = 0
66+
errorHTMLNode.style.left = 0
67+
errorHTMLNode.style.padding = '20px'
68+
errorHTMLNode.style.backgroundColor = 'rgba(0, 0, 0, .7)'
69+
errorHTMLNode.style.boxSizing = 'border-box'
70+
errorHTMLNode.style.lineHeight = '20px'
71+
errorHTMLNode.style.zIndex = 50000
72+
document.body.appendChild(errorHTMLNode)
73+
74+
var socket = io('http://localhost:${port}')
75+
socket.on('onError', function (errorHTML) {
76+
errorHTMLNode.innerHTML = errorHTML
77+
errorHTMLNode.style.display = 'block'
78+
})
79+
80+
socket.on('noError', function () {
81+
errorHTMLNode.style.display = 'none'
82+
})
83+
`)
84+
85+
res.end()
86+
}
87+
}

build/tslint.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
emitErrors: true,
3+
failOnHint: process.env.NODE_ENV === 'production',
4+
typeCheck: true
5+
}

build/uglify.conf.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
compress: {
3+
booleans: true,
4+
cascade: true,
5+
conditionals: true,
6+
comparisons: true,
7+
dead_code: true,
8+
drop_debugger: true,
9+
evaluate: true,
10+
hoist_funs: true,
11+
if_return: true,
12+
join_vars: true,
13+
loops: true,
14+
sequences: true,
15+
toplevel: true,
16+
warnings: false,
17+
unused: true
18+
},
19+
20+
mangle: {
21+
toplevel: true
22+
},
23+
24+
toplevel: true
25+
}

build/utils/build.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// https://github.com/shelljs/shelljs
2+
require('./check-versions')()
3+
4+
process.env.NODE_ENV = 'production'
5+
6+
var ora = require('ora')
7+
var path = require('path')
8+
var chalk = require('chalk')
9+
var shell = require('shelljs')
10+
var webpack = require('webpack')
11+
var config = require('../../config/index')
12+
var webpackConfig = require('./../webpack.prod.conf.js')
13+
14+
var spinner = ora('building for production...')
15+
spinner.start()
16+
17+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
18+
shell.rm('-rf', assetsPath)
19+
shell.mkdir('-p', assetsPath)
20+
shell.config.silent = true
21+
shell.cp('-R', 'static/*', assetsPath)
22+
shell.config.silent = false
23+
24+
webpack(webpackConfig, function (err, stats) {
25+
spinner.stop()
26+
if (err) throw err
27+
process.stdout.write(stats.toString({
28+
colors: true,
29+
modules: false,
30+
children: false,
31+
chunks: false,
32+
chunkModules: false
33+
}) + '\n\n')
34+
35+
console.log(chalk.cyan(' Build complete.\n'))
36+
console.log(chalk.yellow(
37+
' Tip: built files are meant to be served over an HTTP server.\n' +
38+
' Opening index.html over file:// won\'t work.\n'
39+
))
40+
})

0 commit comments

Comments
 (0)