Skip to content

Commit d02f2a6

Browse files
committed
Initial commit
0 parents  commit d02f2a6

29 files changed

+815
-0
lines changed

.babelrc

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

.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

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

.eslintrc.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
root: true,
3+
parser: 'babel-eslint',
4+
parserOptions: {
5+
sourceType: 'module'
6+
},
7+
extends: 'airbnb-base',
8+
// required to lint *.vue files
9+
plugins: [
10+
'html'
11+
],
12+
// check if imports actually resolve
13+
'settings': {
14+
'import/resolver': {
15+
'webpack': {
16+
'config': 'build/webpack.base.conf.js'
17+
}
18+
}
19+
},
20+
// add your custom rules here
21+
'rules': {
22+
// don't require .vue extension when importing
23+
'import/extensions': ['error', 'always', {
24+
'js': 'never',
25+
'vue': 'never'
26+
}],
27+
// allow debugger during development
28+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
29+
}
30+
}

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.DS_Store
2+
node_modules/
3+
4+
# Editor files
5+
/.idea
6+
*.suo
7+
*.ntvs*
8+
*.njsproj
9+
*.sln
10+
11+
# Log files
12+
*.log
13+
reports
14+
coverage
15+
16+
# Build
17+
dist
18+
19+
# Docs
20+
_book
21+
.tmp
22+
tmp*

Clock.vue

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<div>
3+
<div class="hour">{{ hours }}</div>
4+
<div class="minutes">{{ minutes }}</div>
5+
</div>
6+
</template>
7+
8+
<script>
9+
function getDate() {
10+
return new Date()
11+
}
12+
const clock = {
13+
name: 'clock',
14+
data() {
15+
return {
16+
minutes: getDate().getMinutes(),
17+
hours: getDate().getHours(),
18+
};
19+
},
20+
};
21+
22+
export default clock;
23+
24+
setInterval(() => {
25+
const date = new Date();
26+
clock.hours = date.getHours();
27+
clock.minutes = date.getMinutes();
28+
}, 1000);
29+
</script>

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# avoriaz-karma-mocha-example
2+
3+
> An example project using avoriaz, karma and mocha to run tests
4+
5+
## Build Setup
6+
7+
``` bash
8+
# install dependencies
9+
npm install
10+
11+
# serve with hot reload at localhost:8080
12+
npm run dev
13+
14+
# build for production with minification
15+
npm run build
16+
17+
# run unit tests
18+
npm run unit
19+
20+
# run all tests
21+
npm test
22+
```
23+
24+
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

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// https://github.com/shelljs/shelljs
2+
require('./check-versions')();
3+
require('shelljs/global');
4+
env.NODE_ENV = 'production';
5+
6+
var path = require('path');
7+
var config = require('../config');
8+
var ora = require('ora');
9+
var webpack = require('webpack');
10+
var webpackConfig = require('./webpack.prod.conf');
11+
12+
console.log(
13+
' Tip:\n' +
14+
' Built files are meant to be served over an HTTP server.\n' +
15+
' Opening index.html over file:// won\'t work.\n'
16+
);
17+
18+
var spinner = ora('building for production...');
19+
spinner.start();
20+
21+
webpack(webpackConfig, function (err, stats) {
22+
spinner.stop();
23+
if (err) throw err;
24+
process.stdout.write(stats.toString({
25+
colors: true,
26+
modules: false,
27+
children: false,
28+
chunks: false,
29+
chunkModules: false
30+
}) + '\n')
31+
});

build/check-versions.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var semver = require('semver');
2+
var chalk = require('chalk');
3+
var packageConfig = require('../package.json');
4+
var exec = function (cmd) {
5+
return require('child_process')
6+
.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

+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

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

build/utils.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
};

build/webpack.base.conf.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
var path = require('path');
2+
var config = require('../config');
3+
var utils = require('./utils');
4+
var projectRoot = path.resolve(__dirname, '../');
5+
6+
module.exports = {
7+
entry: {
8+
app: './src/main.js'
9+
},
10+
output: {
11+
path: config.build.assetsRoot,
12+
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
13+
filename: '[name].js'
14+
},
15+
resolve: {
16+
extensions: ['', '.js', '.vue', '.json'],
17+
fallback: [path.join(__dirname, '../node_modules')],
18+
alias: {
19+
'vue$': 'vue/dist/vue.common.js',
20+
'src': path.resolve(__dirname, '../src'),
21+
'components': path.resolve(__dirname, '../src/components')
22+
}
23+
},
24+
resolveLoader: {
25+
fallback: [path.join(__dirname, '../node_modules')]
26+
},
27+
module: {
28+
loaders: [
29+
{
30+
test: /\.vue$/,
31+
loader: 'vue'
32+
},
33+
{
34+
test: /\.js$/,
35+
loader: 'babel',
36+
include: [
37+
path.join(projectRoot, 'src')
38+
],
39+
exclude: /node_modules/
40+
},
41+
{
42+
test: /\.json$/,
43+
loader: 'json'
44+
},
45+
]
46+
}
47+
};

build/webpack.dev.conf.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var config = require('../config')
2+
var webpack = require('webpack')
3+
var merge = require('webpack-merge')
4+
var utils = require('./utils')
5+
var baseWebpackConfig = require('./webpack.base.conf')
6+
var HtmlWebpackPlugin = require('html-webpack-plugin')
7+
var FriendlyErrors = require('friendly-errors-webpack-plugin')
8+
9+
// add hot-reload related code to entry chunks
10+
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
11+
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
12+
})
13+
14+
module.exports = merge(baseWebpackConfig, {
15+
// eval-source-map is faster for development
16+
devtool: '#eval-source-map',
17+
plugins: [
18+
new webpack.DefinePlugin({
19+
'process.env': config.dev.env
20+
}),
21+
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
22+
new webpack.optimize.OccurrenceOrderPlugin(),
23+
new webpack.HotModuleReplacementPlugin(),
24+
new webpack.NoErrorsPlugin(),
25+
// https://github.com/ampedandwired/html-webpack-plugin
26+
new HtmlWebpackPlugin({
27+
filename: 'index.html',
28+
template: 'index.html',
29+
inject: true
30+
}),
31+
new FriendlyErrors()
32+
]
33+
})

0 commit comments

Comments
 (0)