Skip to content

Commit 729fb78

Browse files
committed
first commit
0 parents  commit 729fb78

26 files changed

+917
-0
lines changed

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": ["es2015", "stage-2"],
3+
"plugins": ["transform-runtime"],
4+
"comments": false
5+
}

.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

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/*.js
2+
config/*.js

.eslintrc.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
root: true,
3+
fix: true,
4+
parser: 'babel-eslint',
5+
parserOptions: {
6+
sourceType: 'module'
7+
},
8+
extends: 'airbnb-base',
9+
plugins: [
10+
'html'
11+
],
12+
'settings': {
13+
'import/resolver': {
14+
'webpack': {
15+
'config': 'build/webpack.base.conf.js'
16+
}
17+
}
18+
},
19+
'rules': {
20+
// don't require .vue extension when importing
21+
'no-new': 0,
22+
'prefer-template': 0,
23+
'no-unused-vars': 0,
24+
'no-console': 0,
25+
'import/extensions': ['error', 'always', {
26+
'js': 'never',
27+
'vue': 'never'
28+
}],
29+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
30+
}
31+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# vue-modal
2+
3+
> A Vue.js project
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+
18+
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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
22+
rm('-rf', assetsPath)
23+
mkdir('-p', assetsPath)
24+
cp('-R', 'static/*', assetsPath)
25+
26+
webpack(webpackConfig, function (err, stats) {
27+
spinner.stop()
28+
if (err) throw err
29+
process.stdout.write(stats.toString({
30+
colors: true,
31+
modules: false,
32+
children: false,
33+
chunks: false,
34+
chunkModules: false
35+
}) + '\n')
36+
})

build/check-versions.js

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

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

0 commit comments

Comments
 (0)