Skip to content

Commit 4985ab2

Browse files
committed
vue-cnode
0 parents  commit 4985ab2

Some content is hidden

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

57 files changed

+2545
-0
lines changed

.babelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"presets": [
3+
["es2015", { "modules": false }],
4+
"stage-2"
5+
],
6+
"plugins": ["transform-runtime"],
7+
"comments": false,
8+
"env": {
9+
"test": {
10+
"plugins": [ "istanbul" ]
11+
}
12+
}
13+
}

.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

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log
5+
.idea/
6+
.project
7+
8+
/yarn.lock
9+
/111.jpg

.travis.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
language: node_js
2+
node_js: stable
3+
# S: Build Lifecycle
4+
# install:
5+
# - npm install
6+
#before_script:
7+
# - npm install -g gulp
8+
before_install:
9+
- export CHROME_BIN=chromium-browser
10+
- export DISPLAY=:99.0
11+
- sh -e /etc/init.d/xvfb start
12+
# script:
13+
# - hexo g
14+
# 构建之后推送到gh-pages
15+
after_script:
16+
- cd ./dist
17+
- git init
18+
- git config user.name "kylin"
19+
- git config user.email "kailinzhou@yeah.net"
20+
- git add .
21+
- git commit -m "TravisCI"
22+
- git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages
23+
# E: Build LifeCycle
24+
# 设置只有master的push才进行构建
25+
branches:
26+
only:
27+
- master
28+
env:
29+
global:
30+
- GH_REF: github.com/Himmas/vue-cnode.git

.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Use IntelliSense to learn about possible Node.js debug attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [{
7+
"type": "node",
8+
"request": "launch",
9+
"name": "启动程序",
10+
"program": "${file}"
11+
},
12+
{
13+
"type": "node",
14+
"request": "attach",
15+
"name": "附加到进程",
16+
"address": "localhost",
17+
"port": 5858
18+
}
19+
]
20+
}

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// 将设置放入此文件中以覆盖默认值和用户设置。
2+
{
3+
"workbench.iconTheme": "vs-seti",
4+
"workbench.colorTheme": "Monokai",
5+
"editor.tabSize": 2,
6+
"files.autoSave": "off",
7+
"beautify.tabSize": 2,
8+
"[vue]": {
9+
"editor.tabSize": 2
10+
11+
}
12+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Himmas
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# vue-cnode
2+
3+
[![Build Status](https://travis-ci.org/Himmas/vue-cnode.svg?branch=master)](https://travis-ci.org/Himmas/vue-cnode)
4+
5+
[Live demo](https://himmas.github.io/vue-cnode/)
6+
7+
## Build Setup
8+
9+
``` bash
10+
# install dependencies
11+
npm install
12+
13+
# serve with hot reload at localhost:8080
14+
npm run dev
15+
16+
# build for production with minification
17+
npm run build
18+
19+
# build for production and view the bundle analyzer report
20+
npm run build --report
21+
```
22+
23+
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

build/build.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
console.log(chalk.cyan(' Build complete.\n'))
30+
console.log(chalk.yellow(
31+
' Tip: built files are meant to be served over an HTTP server.\n' +
32+
' Opening index.html over file:// won\'t work.\n'
33+
))
34+
})
35+
})

build/check-versions.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var chalk = require('chalk')
2+
var semver = require('semver')
3+
var packageConfig = require('../package.json')
4+
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+
name: 'npm',
17+
currentVersion: exec('npm --version'),
18+
versionRequirement: packageConfig.engines.npm
19+
}
20+
]
21+
22+
module.exports = function () {
23+
var warnings = []
24+
for (var i = 0; i < versionRequirements.length; i++) {
25+
var mod = versionRequirements[i]
26+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
27+
warnings.push(mod.name + ': ' +
28+
chalk.red(mod.currentVersion) + ' should be ' +
29+
chalk.green(mod.versionRequirement)
30+
)
31+
}
32+
}
33+
34+
if (warnings.length) {
35+
console.log('')
36+
console.log(chalk.yellow('To use this template, you must update following to modules:'))
37+
console.log()
38+
for (var i = 0; i < warnings.length; i++) {
39+
var warning = warnings[i]
40+
console.log(' ' + warning)
41+
}
42+
console.log()
43+
process.exit(1)
44+
}
45+
}

build/dev-client.js

Lines changed: 9 additions & 0 deletions
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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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 webpackConfig = require('./webpack.dev.conf')
14+
15+
// default port where dev server listens for incoming traffic
16+
var port = process.env.PORT || config.dev.port
17+
// automatically open browser, if not set will be false
18+
var autoOpenBrowser = !!config.dev.autoOpenBrowser
19+
// Define HTTP proxies to your custom API backend
20+
// https://github.com/chimurai/http-proxy-middleware
21+
var proxyTable = config.dev.proxyTable
22+
23+
var app = express()
24+
var compiler = webpack(webpackConfig)
25+
26+
var devMiddleware = require('webpack-dev-middleware')(compiler, {
27+
publicPath: webpackConfig.output.publicPath,
28+
quiet: true
29+
})
30+
31+
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
32+
log: () => {}
33+
})
34+
// force page reload when html-webpack-plugin template changes
35+
compiler.plugin('compilation', function (compilation) {
36+
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
37+
hotMiddleware.publish({ action: 'reload' })
38+
cb()
39+
})
40+
})
41+
42+
// proxy api requests
43+
Object.keys(proxyTable).forEach(function (context) {
44+
var options = proxyTable[context]
45+
if (typeof options === 'string') {
46+
options = { target: options }
47+
}
48+
app.use(proxyMiddleware(options.filter || context, options))
49+
})
50+
51+
// handle fallback for HTML5 history API
52+
app.use(require('connect-history-api-fallback')())
53+
54+
// serve webpack bundle output
55+
app.use(devMiddleware)
56+
57+
// enable hot-reload and state-preserving
58+
// compilation error display
59+
app.use(hotMiddleware)
60+
61+
// serve pure static assets
62+
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
63+
app.use(staticPath, express.static('./static'))
64+
65+
var uri = 'http://localhost:' + port
66+
67+
devMiddleware.waitUntilValid(function () {
68+
console.log('> Listening at ' + uri + '\n')
69+
})
70+
71+
module.exports = app.listen(port, function (err) {
72+
if (err) {
73+
console.log(err)
74+
return
75+
}
76+
77+
// when env is testing, don't need open it
78+
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
79+
opn(uri)
80+
}
81+
})

build/utils.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
// generate loader string to be used with extract text plugin
24+
function generateLoaders (loader, loaderOptions) {
25+
var loaders = [cssLoader]
26+
if (loader) {
27+
loaders.push({
28+
loader: loader + '-loader',
29+
options: Object.assign({}, loaderOptions, {
30+
sourceMap: options.sourceMap
31+
})
32+
})
33+
}
34+
35+
// Extract CSS when that option is specified
36+
// (which is the case during production build)
37+
if (options.extract) {
38+
return ExtractTextPlugin.extract({
39+
use: loaders,
40+
fallback: 'vue-style-loader'
41+
})
42+
} else {
43+
return ['vue-style-loader'].concat(loaders)
44+
}
45+
}
46+
47+
// http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
48+
return {
49+
css: generateLoaders(),
50+
postcss: generateLoaders(),
51+
less: generateLoaders('less'),
52+
sass: generateLoaders('sass', { indentedSyntax: true }),
53+
scss: generateLoaders('sass'),
54+
stylus: generateLoaders('stylus'),
55+
styl: generateLoaders('stylus')
56+
}
57+
}
58+
59+
// Generate loaders for standalone style files (outside of .vue)
60+
exports.styleLoaders = function (options) {
61+
var output = []
62+
var loaders = exports.cssLoaders(options)
63+
for (var extension in loaders) {
64+
var loader = loaders[extension]
65+
output.push({
66+
test: new RegExp('\\.' + extension + '$'),
67+
use: loader
68+
})
69+
}
70+
return output
71+
}

0 commit comments

Comments
 (0)