Skip to content

Commit 73f724f

Browse files
author
ivan
committed
'first'
0 parents  commit 73f724f

File tree

189 files changed

+16919
-0
lines changed

Some content is hidden

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

189 files changed

+16919
-0
lines changed

.babelrc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"modules": false,
5+
"targets": {
6+
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7+
}
8+
}],
9+
"stage-2"
10+
],
11+
"plugins": ["transform-runtime"],
12+
"env": {
13+
"test": {
14+
"presets": ["env", "stage-2"],
15+
"plugins": ["istanbul"]
16+
}
17+
}
18+
}

.editorconfig

+9
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

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/*.js
2+
config/*.js
3+
static/

.eslintrc.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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: false,
11+
node: true,
12+
es6: true
13+
},
14+
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
15+
extends: 'standard',
16+
// required to lint *.vue files
17+
plugins: [
18+
'html'
19+
],
20+
// add your custom rules here
21+
'rules': {
22+
// allow paren-less arrow functions
23+
'arrow-parens': 0,
24+
// allow async-await
25+
'generator-star-spacing': 0,
26+
// allow debugger during development
27+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
28+
'semi': 'off'
29+
},
30+
globals: {
31+
App: true,
32+
Page: true,
33+
wx: true,
34+
getApp: true,
35+
getPage: true
36+
}
37+
}

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Editor directories and files
9+
.idea
10+
*.suo
11+
*.ntvs*
12+
*.njsproj
13+
*.sln

.postcssrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
"postcss-mpvue-wxss": {}
8+
}
9+
}

README.md

Whitespace-only changes.

build/build.js

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

build/check-versions.js

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

build/dev-client.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable */
2+
require('eventsource-polyfill')
3+
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4+
5+
hotClient.subscribe(function (event) {
6+
if (event.action === 'reload') {
7+
window.location.reload()
8+
}
9+
})

build/dev-server.js

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
require('./check-versions')()
2+
3+
var config = require('../config')
4+
if (!process.env.NODE_ENV) {
5+
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
6+
}
7+
8+
// var opn = require('opn')
9+
var path = require('path')
10+
var express = require('express')
11+
var webpack = require('webpack')
12+
var proxyMiddleware = require('http-proxy-middleware')
13+
var portfinder = require('portfinder')
14+
var webpackConfig = require('./webpack.dev.conf')
15+
16+
// default port where dev server listens for incoming traffic
17+
var port = process.env.PORT || config.dev.port
18+
// automatically open browser, if not set will be false
19+
var autoOpenBrowser = !!config.dev.autoOpenBrowser
20+
// Define HTTP proxies to your custom API backend
21+
// https://github.com/chimurai/http-proxy-middleware
22+
var proxyTable = config.dev.proxyTable
23+
24+
var app = express()
25+
var compiler = webpack(webpackConfig)
26+
27+
// var devMiddleware = require('webpack-dev-middleware')(compiler, {
28+
// publicPath: webpackConfig.output.publicPath,
29+
// quiet: true
30+
// })
31+
32+
// var hotMiddleware = require('webpack-hot-middleware')(compiler, {
33+
// log: false,
34+
// heartbeat: 2000
35+
// })
36+
// force page reload when html-webpack-plugin template changes
37+
// compiler.plugin('compilation', function (compilation) {
38+
// compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
39+
// hotMiddleware.publish({ action: 'reload' })
40+
// cb()
41+
// })
42+
// })
43+
44+
// proxy api requests
45+
Object.keys(proxyTable).forEach(function (context) {
46+
var options = proxyTable[context]
47+
if (typeof options === 'string') {
48+
options = {
49+
target: options
50+
}
51+
}
52+
app.use(proxyMiddleware(options.filter || context, options))
53+
})
54+
55+
// handle fallback for HTML5 history API
56+
app.use(require('connect-history-api-fallback')())
57+
58+
// serve webpack bundle output
59+
// app.use(devMiddleware)
60+
61+
// enable hot-reload and state-preserving
62+
// compilation error display
63+
// app.use(hotMiddleware)
64+
65+
// serve pure static assets
66+
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
67+
app.use(staticPath, express.static('./static'))
68+
69+
// var uri = 'http://localhost:' + port
70+
71+
var _resolve
72+
var readyPromise = new Promise(resolve => {
73+
_resolve = resolve
74+
})
75+
76+
// console.log('> Starting dev server...')
77+
// devMiddleware.waitUntilValid(() => {
78+
// console.log('> Listening at ' + uri + '\n')
79+
// // when env is testing, don't need open it
80+
// if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
81+
// opn(uri)
82+
// }
83+
// _resolve()
84+
// })
85+
86+
module.exports = new Promise((resolve, reject) => {
87+
portfinder.basePort = port
88+
portfinder.getPortPromise()
89+
.then(newPort => {
90+
if (port !== newPort) {
91+
console.log(`${port}端口被占用,开启新端口${newPort}`)
92+
}
93+
var server = app.listen(newPort, 'localhost')
94+
// for 小程序的文件保存机制
95+
require('webpack-dev-middleware-hard-disk')(compiler, {
96+
publicPath: webpackConfig.output.publicPath,
97+
quiet: true
98+
})
99+
resolve({
100+
ready: readyPromise,
101+
close: () => {
102+
server.close()
103+
}
104+
})
105+
}).catch(error => {
106+
console.log('没有找到空闲端口,请打开任务管理器杀死进程端口再试', error)
107+
})
108+
})

build/utils.js

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
4+
5+
exports.assetsPath = function (_path) {
6+
var assetsSubDirectory = process.env.NODE_ENV === 'production'
7+
? config.build.assetsSubDirectory
8+
: config.dev.assetsSubDirectory
9+
return path.posix.join(assetsSubDirectory, _path)
10+
}
11+
12+
exports.cssLoaders = function (options) {
13+
options = options || {}
14+
15+
var cssLoader = {
16+
loader: 'css-loader',
17+
options: {
18+
minimize: process.env.NODE_ENV === 'production',
19+
sourceMap: options.sourceMap
20+
}
21+
}
22+
23+
var postcssLoader = {
24+
loader: 'postcss-loader',
25+
options: {
26+
sourceMap: true
27+
}
28+
}
29+
30+
var px2rpxLoader = {
31+
loader: 'px2rpx-loader',
32+
options: {
33+
baseDpr: 1,
34+
rpxUnit: 0.5
35+
}
36+
}
37+
38+
// generate loader string to be used with extract text plugin
39+
function generateLoaders (loader, loaderOptions) {
40+
var loaders = [cssLoader, postcssLoader, px2rpxLoader]
41+
if (loader) {
42+
loaders.push({
43+
loader: loader + '-loader',
44+
options: Object.assign({}, loaderOptions, {
45+
sourceMap: options.sourceMap
46+
})
47+
})
48+
}
49+
50+
// Extract CSS when that option is specified
51+
// (which is the case during production build)
52+
if (options.extract) {
53+
return ExtractTextPlugin.extract({
54+
use: loaders,
55+
fallback: 'vue-style-loader'
56+
})
57+
} else {
58+
return ['vue-style-loader'].concat(loaders)
59+
}
60+
}
61+
62+
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
63+
return {
64+
css: generateLoaders(),
65+
postcss: generateLoaders(),
66+
less: generateLoaders('less'),
67+
sass: generateLoaders('sass', { indentedSyntax: true }),
68+
scss: generateLoaders('sass'),
69+
stylus: generateLoaders('stylus'),
70+
styl: generateLoaders('stylus')
71+
}
72+
}
73+
74+
// Generate loaders for standalone style files (outside of .vue)
75+
exports.styleLoaders = function (options) {
76+
var output = []
77+
var loaders = exports.cssLoaders(options)
78+
for (var extension in loaders) {
79+
var loader = loaders[extension]
80+
output.push({
81+
test: new RegExp('\\.' + extension + '$'),
82+
use: loader
83+
})
84+
}
85+
return output
86+
}

0 commit comments

Comments
 (0)