mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-09 19:12:24 +03:00
start preparing examples & tests
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import Vue from 'vue'
|
||||
import VueMeta from 'vue-meta'
|
||||
|
||||
Vue.use(VueMeta)
|
||||
|
||||
new Vue({
|
||||
template: `
|
||||
<div id="app">
|
||||
<h1>Basic</h1>
|
||||
<p>Inspect Element to see the meta info</p>
|
||||
</div>
|
||||
`,
|
||||
metaInfo: {
|
||||
title: 'Basic',
|
||||
titleTemplate: '%s | Vue Meta Examples',
|
||||
htmlAttrs: {
|
||||
lang: 'en',
|
||||
amp: undefined
|
||||
}
|
||||
}
|
||||
}).$mount('#app')
|
||||
@@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<link rel="stylesheet" href="/global.css">
|
||||
<a href="/">← Examples index</a>
|
||||
<div id="app"></div>
|
||||
<script src="/__build__/basic.js"></script>
|
||||
@@ -0,0 +1,22 @@
|
||||
html, body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
#app {
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
ul {
|
||||
line-height: 1.5em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #7f8c8d;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #4fc08d;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Vue Meta Examples</title>
|
||||
<link rel="stylesheet" href="/global.css">
|
||||
</head>
|
||||
<body style="padding: 0 20px">
|
||||
<h1>Vue Meta Examples</h1>
|
||||
<ul>
|
||||
<li><a href="basic">Basic</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,30 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const express = require('express')
|
||||
const rewrite = require('express-urlrewrite')
|
||||
const webpack = require('webpack')
|
||||
const webpackDevMiddleware = require('webpack-dev-middleware')
|
||||
const WebpackConfig = require('./webpack.config')
|
||||
|
||||
const app = express()
|
||||
|
||||
app.use(webpackDevMiddleware(webpack(WebpackConfig), {
|
||||
publicPath: '/__build__/',
|
||||
stats: {
|
||||
colors: true,
|
||||
chunks: false
|
||||
}
|
||||
}))
|
||||
|
||||
fs.readdirSync(__dirname).forEach(file => {
|
||||
if (fs.statSync(path.join(__dirname, file)).isDirectory()) {
|
||||
app.use(rewrite('/' + file + '/*', '/' + file + '/index.html'))
|
||||
}
|
||||
})
|
||||
|
||||
app.use(express.static(__dirname))
|
||||
|
||||
const port = process.env.PORT || 8080
|
||||
module.exports = app.listen(port, () => {
|
||||
console.log(`Server listening on http://localhost:${port}, Ctrl+C to stop`)
|
||||
})
|
||||
@@ -0,0 +1,53 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
|
||||
module.exports = {
|
||||
|
||||
devtool: 'inline-source-map',
|
||||
|
||||
entry: fs.readdirSync(__dirname).reduce((entries, dir) => {
|
||||
const fullDir = path.join(__dirname, dir)
|
||||
const entry = path.join(fullDir, 'app.js')
|
||||
if (fs.statSync(fullDir).isDirectory() && fs.existsSync(entry)) {
|
||||
entries[dir] = entry
|
||||
}
|
||||
|
||||
return entries
|
||||
}, {}),
|
||||
|
||||
output: {
|
||||
path: path.join(__dirname, '__build__'),
|
||||
filename: '[name].js',
|
||||
chunkFilename: '[id].chunk.js',
|
||||
publicPath: '/__build__/'
|
||||
},
|
||||
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
|
||||
{ test: /\.vue$/, loader: 'vue' }
|
||||
]
|
||||
},
|
||||
|
||||
resolve: {
|
||||
alias: {
|
||||
'vue': 'vue/dist/vue.js',
|
||||
'vue-meta': path.join(__dirname, '..', 'src')
|
||||
}
|
||||
},
|
||||
|
||||
// Expose __dirname to allow automatically setting basename.
|
||||
context: __dirname,
|
||||
node: {
|
||||
__dirname: true
|
||||
},
|
||||
|
||||
plugins: [
|
||||
// new webpack.optimize.CommonsChunkPlugin('shared.js'),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
|
||||
})
|
||||
]
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// we can just use the exact same webpack config by requiring it
|
||||
// however, remember to delete the original entry since we don't
|
||||
// need it during tests
|
||||
var webpackConfig = require('./examples/webpack.config.js')
|
||||
delete webpackConfig.entry
|
||||
|
||||
// karma.conf.js
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
browsers: ['PhantomJS'],
|
||||
frameworks: ['mocha', 'chai'],
|
||||
// this is the entry file for all our tests.
|
||||
files: ['test/index.js'],
|
||||
// we will pass the entry file to webpack for bundling.
|
||||
preprocessors: {
|
||||
'test/index.js': ['webpack']
|
||||
},
|
||||
// use the webpack config
|
||||
webpack: webpackConfig,
|
||||
// avoid walls of useless text
|
||||
webpackMiddleware: {
|
||||
noInfo: true
|
||||
},
|
||||
singleRun: true
|
||||
})
|
||||
}
|
||||
+26
-2
@@ -5,14 +5,33 @@
|
||||
"author": "Declan de Wet <declandewet@me.com>",
|
||||
"bugs": "https://github.com/declandewet/vue-meta/issues",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.18.0",
|
||||
"babel-loader": "^6.2.7",
|
||||
"babel-preset-es2015": "^6.18.0",
|
||||
"chai": "^3.5.0",
|
||||
"css-loader": "^0.25.0",
|
||||
"doctoc": "^1.2.0",
|
||||
"express": "^4.14.0",
|
||||
"express-urlrewrite": "^1.2.0",
|
||||
"file-loader": "^0.9.0",
|
||||
"karma": "^1.3.0",
|
||||
"karma-chai": "^0.1.0",
|
||||
"karma-mocha": "^1.2.0",
|
||||
"karma-phantomjs-launcher": "^1.0.2",
|
||||
"karma-webpack": "^1.8.0",
|
||||
"mocha": "^3.1.2",
|
||||
"phantomjs": "^2.1.7+deprecated",
|
||||
"rimraf": "^2.5.4",
|
||||
"rollup": "^0.36.3",
|
||||
"rollup-plugin-buble": "^0.14.0",
|
||||
"rollup-plugin-commonjs": "^5.0.5",
|
||||
"rollup-plugin-node-resolve": "^2.0.0",
|
||||
"snazzy": "^5.0.0",
|
||||
"standard": "^8.5.0"
|
||||
"standard": "^8.5.0",
|
||||
"vue": "^2.0.3",
|
||||
"vue-loader": "^9.7.0",
|
||||
"webpack": "beta",
|
||||
"webpack-dev-server": "beta"
|
||||
},
|
||||
"homepage": "https://github.com/declandewet/vue-meta",
|
||||
"keywords": [
|
||||
@@ -36,8 +55,10 @@
|
||||
"type": "git"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "node examples/server.js",
|
||||
"build": "rollup -c",
|
||||
"lint": "standard --verbose | snazzy",
|
||||
"test": "karma start karma.conf.js",
|
||||
"prebuild": "rimraf lib",
|
||||
"pretest": "npm run lint",
|
||||
"toc": "doctoc README.md --title '# Table of Contents'"
|
||||
@@ -45,7 +66,10 @@
|
||||
"standard": {
|
||||
"globals": [
|
||||
"Vue",
|
||||
"define"
|
||||
"define",
|
||||
"describe",
|
||||
"it",
|
||||
"expect"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
describe('basic', function () {
|
||||
it('does something', function () {
|
||||
console.log('tests have yet to be written')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
// test/index.js
|
||||
// require all test files using special Webpack feature
|
||||
// https://webpack.github.io/docs/context.html#require-context
|
||||
var testsContext = require.context('.', true, /\.spec$/)
|
||||
testsContext.keys().forEach(testsContext)
|
||||
Reference in New Issue
Block a user