Skip to content

Commit

Permalink
simplify examples setup
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 28, 2016
1 parent 94d85b5 commit 069109b
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 83 deletions.
File renamed without changes.
3 changes: 2 additions & 1 deletion examples/chat/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</head>
<body>
<div id="app"></div>
<script src="build.js"></script>
<script src="/__build__/shared.js"></script>
<script src="/__build__/chat.js"></script>
</body>
</html>
File renamed without changes.
4 changes: 3 additions & 1 deletion examples/counter-hot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<head>
<meta charset="utf-8">
<title>vuex counter example</title>
<link rel="stylesheet" href="/global.css">
</head>
<body>
<div id="app"></div>
<script src="build.js"></script>
<script src="/__build__/shared.js"></script>
<script src="/__build__/counter-hot.js"></script>
</body>
</html>
File renamed without changes.
4 changes: 3 additions & 1 deletion examples/counter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<head>
<meta charset="utf-8">
<title>vuex counter example</title>
<link rel="stylesheet" href="/global.css">
</head>
<body>
<div id="app"></div>
<script src="build.js"></script>
<script src="/__build__/shared.js"></script>
<script src="/__build__/counter.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions examples/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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;
}

ul {
line-height: 1.5em;
padding-left: 1.5em;
}

a {
color: #7f8c8d;
text-decoration: none;
}

a:hover {
color: #4fc08d;
}
18 changes: 18 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vuex Examples</title>
<link rel="stylesheet" href="/global.css">
</head>
<body style="padding: 0 20px">
<h1>Vuex Examples</h1>
<ul>
<li><a href="counter">Counter</a></li>
<li><a href="counter-hot">Counter with Hot Reload</a></li>
<li><a href="shopping-cart">Shopping Cart</a></li>
<li><a href="todomvc">TodoMVC</a></li>
<li><a href="chat">FluxChat</a></li>
</ul>
</body>
</html>
File renamed without changes.
4 changes: 3 additions & 1 deletion examples/shopping-cart/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<head>
<meta charset="utf-8">
<title>vuex shopping cart example</title>
<link rel="stylesheet" href="/global.css">
</head>
<body>
<div id="app"></div>
<script src="build.js"></script>
<script src="/__build__/shared.js"></script>
<script src="/__build__/shopping-cart.js"></script>
</body>
</html>
File renamed without changes.
3 changes: 2 additions & 1 deletion examples/todomvc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</head>
<body>
<div id="app"></div>
<script src="build.js"></script>
<script src="/__build__/shared.js"></script>
<script src="/__build__/todomvc.js"></script>
</body>
</html>
40 changes: 0 additions & 40 deletions examples/webpack.build-all.config.js

This file was deleted.

46 changes: 46 additions & 0 deletions examples/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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: {
vuex: path.resolve(__dirname, '../build/dev-entry')
}
},

plugins: [
new webpack.optimize.CommonsChunkPlugin('shared.js'),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
})
]

}
28 changes: 0 additions & 28 deletions examples/webpack.shared.config.js

This file was deleted.

15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@
"logger.js"
],
"scripts": {
"counter": "cd examples/counter && webpack-dev-server --inline --hot --config ../webpack.shared.config.js",
"counter-hot": "cd examples/counter-hot && webpack-dev-server --inline --hot --config ../webpack.shared.config.js",
"todomvc": "cd examples/todomvc && webpack-dev-server --inline --hot --config ../webpack.shared.config.js",
"cart": "cd examples/shopping-cart && webpack-dev-server --inline --hot --config ../webpack.shared.config.js",
"chat": "cd examples/chat && webpack-dev-server --inline --hot --config ../webpack.shared.config.js",
"build": "node build/build.js",
"build-examples": "BABEL_ENV=development webpack --config examples/webpack.build-all.config.js",
"dev": "cd examples && webpack-dev-server --inline --hot --no-info",
"test": "eslint src && npm run test:unit && npm run test:e2e",
"test:unit": "cross-env BABEL_ENV=development jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
"test:unit": "jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json",
"test:e2e": "npm run build-examples && casperjs test --concise ./test/e2e",
"build": "node build/build.js",
"release": "bash build/release.sh",
"docs": "cd docs && gitbook serve",
"deploy-docs": "cd docs && ./deploy.sh",
"release": "bash build/release.sh"
"docs:deploy": "cd docs && ./deploy.sh"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 069109b

Please sign in to comment.