Skip to content

Commit 3256302

Browse files
committed
Init project
0 parents  commit 3256302

Some content is hidden

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

48 files changed

+52293
-0
lines changed

.babelrc

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

.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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// http://eslint.org/docs/user-guide/configuring
2+
3+
module.exports = {
4+
root: true,
5+
parser: 'babel-eslint',
6+
parserOptions: {
7+
sourceType: 'module'
8+
},
9+
env: {
10+
browser: true,
11+
},
12+
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
13+
extends: 'standard',
14+
// required to lint *.vue files
15+
plugins: [
16+
'html'
17+
],
18+
// add your custom rules here
19+
'rules': {
20+
// allow paren-less arrow functions
21+
'arrow-parens': 0,
22+
// allow async-await
23+
'generator-star-spacing': 0,
24+
// allow debugger during development
25+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26+
}
27+
}

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*

.postcssrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// https://github.com/michael-ciniawsky/postcss-load-config
2+
3+
module.exports = {
4+
"plugins": {
5+
// to edit target browsers: use "browserlist" field in package.json
6+
"autoprefixer": {}
7+
}
8+
}

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# XSS demo using Vue
2+
3+
This [demo](https://sqreen.github.io/vuexssdemo/) demonstrate how to perform XSS injection with Vue, Vux and Iview.
4+
5+
It's part of this article regarding XSS in Vue.
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 and view the bundle analyzer report
17+
npm run build --report
18+
```
19+
20+
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

+35
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

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

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

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
var _resolve
68+
var readyPromise = new Promise(resolve => {
69+
_resolve = resolve
70+
})
71+
72+
console.log('> Starting dev server...')
73+
devMiddleware.waitUntilValid(() => {
74+
console.log('> Listening at ' + uri + '\n')
75+
// when env is testing, don't need open it
76+
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
77+
opn(uri)
78+
}
79+
_resolve()
80+
})
81+
82+
var server = app.listen(port)
83+
84+
module.exports = {
85+
ready: readyPromise,
86+
close: () => {
87+
server.close()
88+
}
89+
}

build/utils.js

+71
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+
// https://vue-loader.vuejs.org/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+
}

build/vue-loader.conf.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var utils = require('./utils')
2+
var config = require('../config')
3+
var isProduction = process.env.NODE_ENV === 'production'
4+
5+
module.exports = {
6+
loaders: utils.cssLoaders({
7+
sourceMap: isProduction
8+
? config.build.productionSourceMap
9+
: config.dev.cssSourceMap,
10+
extract: isProduction
11+
})
12+
}

0 commit comments

Comments
 (0)