forked from haozi/xss-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8e02aca
Showing
40 changed files
with
6,365 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": ["es2015", "stage-2"], | ||
"plugins": ["transform-runtime"], | ||
"comments": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
/*global env rm mkdir cp*/ | ||
|
||
require('shelljs/global') | ||
env.NODE_ENV = 'production' | ||
|
||
const path = require('path') | ||
const config = require('./config') | ||
const ora = require('ora') | ||
const webpack = require('webpack') | ||
const webpackConfig = require('./webpack.prod.conf') | ||
|
||
const spinner = ora('building for production...') | ||
spinner.start() | ||
|
||
const assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory) | ||
rm('-rf', assetsPath) | ||
mkdir('-p', assetsPath) | ||
cp('-R', 'static/*', assetsPath) | ||
|
||
webpack(webpackConfig, function (err, stats) { | ||
spinner.stop() | ||
if (err) throw err | ||
process.stdout.write(stats.toString({ | ||
colors: true, | ||
modules: false, | ||
children: false, | ||
chunks: false, | ||
chunkModules: false | ||
}) + '\n') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict' | ||
const merge = require('webpack-merge') | ||
const prodEnv = require('./prod.env.js') | ||
|
||
module.exports = merge(prodEnv, { | ||
NODE_ENV: '"development"' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
const path = require('path') | ||
|
||
module.exports = { | ||
autoprefixer: { | ||
browsers: ['Android >= 4', 'iOS >= 7', 'IE >= 9', 'Firefox >= 50', 'Chrome >= 21'], | ||
}, | ||
build: { | ||
env: require('./prod.env.js'), | ||
index: path.resolve(__dirname, '../../build/index.html'), | ||
assetsRoot: path.resolve(__dirname, '../../build'), | ||
assetsSubDirectory: './', | ||
assetsPublicPath: '', | ||
productionSourceMap: false, | ||
productionGzip: false, | ||
linkCss: false, | ||
vendor: false, | ||
buildHtml: true, | ||
productionGzipExtensions: ['js', 'css'], | ||
}, | ||
dev: { | ||
env: require('./dev.env.js'), | ||
port: 8080, | ||
assetsSubDirectory: 'static', | ||
assetsPublicPath: '/', | ||
proxyTable: {}, | ||
cssSourceMap: false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict' | ||
module.exports = { | ||
NODE_ENV: '"production"' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict' | ||
|
||
const merge = require('webpack-merge') | ||
const devEnv = require('./dev.env.js') | ||
|
||
module.exports = merge(devEnv, { | ||
NODE_ENV: '"testing"' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict' | ||
|
||
/* eslint-disable */ | ||
require('eventsource-polyfill') | ||
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') | ||
|
||
hotClient.subscribe(function (event) { | ||
if (event.action === 'reload') { | ||
window.location.reload() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict' | ||
let config = require('./config') | ||
if (!process.env.NODE_ENV) process.env.NODE_ENV = config.dev.env | ||
let path = require('path') | ||
let express = require('express') | ||
let webpack = require('webpack') | ||
let proxyMiddleware = require('http-proxy-middleware') | ||
let webpackConfig = process.env.NODE_ENV === 'testing' | ||
? require('./webpack.prod.conf') | ||
: require('./webpack.dev.conf') | ||
|
||
let port = process.env.PORT || config.dev.port | ||
let proxyTable = config.dev.proxyTable | ||
|
||
let app = express() | ||
let compiler = webpack(webpackConfig) | ||
|
||
let devMiddleware = require('webpack-dev-middleware')(compiler, { | ||
publicPath: webpackConfig.output.publicPath, | ||
stats: { | ||
colors: true, | ||
chunks: false | ||
} | ||
}) | ||
|
||
let hotMiddleware = require('webpack-hot-middleware')(compiler) | ||
compiler.plugin('compilation', function (compilation) { | ||
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { | ||
hotMiddleware.publish({ action: 'reload' }) | ||
cb() | ||
}) | ||
}) | ||
|
||
Object.keys(proxyTable).forEach(function (context) { | ||
let options = proxyTable[context] | ||
if (typeof options === 'string') { | ||
options = { target: options } | ||
} | ||
app.use(proxyMiddleware(context, options)) | ||
}) | ||
|
||
app.use(require('connect-history-api-fallback')()) | ||
|
||
app.use(devMiddleware) | ||
|
||
app.use(hotMiddleware) | ||
|
||
let staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) | ||
app.use(staticPath, express.static('./static')) | ||
|
||
module.exports = app.listen(port, function (err) { | ||
if (err) { | ||
console.log(err) | ||
return | ||
} | ||
let uri = 'http://127.0.0.1:' + port | ||
console.log('Listening at ' + uri + '\n') | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict' | ||
let path = require('path') | ||
let config = require('./config') | ||
let ExtractTextPlugin = require('extract-text-webpack-plugin') | ||
|
||
exports.assetsPath = function (_path) { | ||
let assetsSubDirectory = process.env.NODE_ENV === 'production' | ||
? config.build.assetsSubDirectory | ||
: config.dev.assetsSubDirectory | ||
return path.posix.join(assetsSubDirectory, _path) | ||
} | ||
|
||
exports.cssLoaders = function (options) { | ||
options = options || {} | ||
function generateLoaders (loaders) { | ||
let sourceLoader = loaders.map(function (loader) { | ||
let extraParamChar | ||
if (/\?/.test(loader)) { | ||
loader = loader.replace(/\?/, '-loader?') | ||
extraParamChar = '&' | ||
} else { | ||
loader = loader + '-loader' | ||
extraParamChar = '?' | ||
} | ||
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '') | ||
}).join('!') | ||
|
||
if (options.extract) { | ||
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader) | ||
} else { | ||
return ['vue-style-loader', sourceLoader].join('!') | ||
} | ||
} | ||
|
||
return { | ||
css: generateLoaders(['css']), | ||
postcss: generateLoaders(['css']), | ||
less: generateLoaders(['css', 'less']), | ||
sass: generateLoaders(['css', 'sass?indentedSyntax']), | ||
scss: generateLoaders(['css', 'sass']), | ||
stylus: generateLoaders(['css', 'stylus']), | ||
styl: generateLoaders(['css', 'stylus']) | ||
} | ||
} | ||
|
||
exports.styleLoaders = function (options) { | ||
let output = [] | ||
let loaders = exports.cssLoaders(options) | ||
for (let extension in loaders) { | ||
let loader = loaders[extension] | ||
output.push({ | ||
test: new RegExp('\\.' + extension + '$'), | ||
loader: loader | ||
}) | ||
} | ||
return output | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
'use strict' | ||
let path = require('path') | ||
let config = require('./config') | ||
let utils = require('./utils') | ||
let projectRoot = path.resolve(__dirname, '../') | ||
|
||
let env = process.env.NODE_ENV | ||
let cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap) | ||
let cssSourceMapProd = (env === 'production' && config.build.productionSourceMap) | ||
let useCssSourceMap = cssSourceMapDev || cssSourceMapProd | ||
|
||
module.exports = { | ||
entry: { | ||
app: './src/main.js' | ||
}, | ||
output: { | ||
path: config.build.assetsRoot, | ||
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath, | ||
filename: '[name].js' | ||
}, | ||
resolve: { | ||
extensions: ['', '.js', '.vue'], | ||
fallback: [path.join(__dirname, '../node_modules')], | ||
alias: { | ||
'vue$': 'vue/dist/vue', | ||
'src': path.resolve(__dirname, '../src'), | ||
'assets': path.resolve(__dirname, '../src/assets'), | ||
'components': path.resolve(__dirname, '../src/components') | ||
} | ||
}, | ||
resolveLoader: { | ||
fallback: [path.join(__dirname, '../node_modules')] | ||
}, | ||
module: { | ||
preLoaders: [ | ||
{ | ||
test: /\.vue$/, | ||
loader: 'eslint', | ||
include: projectRoot, | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
test: /\.js$/, | ||
loader: 'eslint', | ||
include: projectRoot, | ||
exclude: /node_modules/ | ||
} | ||
], | ||
loaders: [ | ||
{ | ||
test: /\.vue$/, | ||
loader: 'vue' | ||
}, | ||
{ | ||
test: /\.js$/, | ||
loader: 'babel', | ||
include: projectRoot, | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
test: /\.css$/, | ||
loader: 'style!css' | ||
}, | ||
{ | ||
test: /\.less$/, | ||
loader: 'style!css?sourceMap!postcss!less?strictMath&noIeCompat&sourceMap' | ||
}, | ||
{ | ||
test: /\.json$/, | ||
loader: 'json' | ||
}, | ||
{ | ||
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, | ||
loader: 'url', | ||
query: { | ||
limit: 10000, | ||
name: utils.assetsPath('img/[name].[ext]') | ||
} | ||
}, | ||
{ | ||
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, | ||
loader: 'url', | ||
query: { | ||
limit: 10000, | ||
name: utils.assetsPath('fonts/[name].[hash:7].[ext]') | ||
} | ||
}, | ||
{ | ||
test: /\.raw$/, | ||
loader: 'raw-loader' | ||
} | ||
] | ||
}, | ||
eslint: { | ||
formatter: require('eslint-friendly-formatter') | ||
}, | ||
vue: { | ||
loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }), | ||
postcss: [ | ||
require('autoprefixer')(config.autoprefixer) | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
const config = require('./config') | ||
const webpack = require('webpack') | ||
const merge = require('webpack-merge') | ||
const utils = require('./utils') | ||
const baseWebpackConfig = require('./webpack.base.conf') | ||
const HtmlWebpackPlugin = require('html-webpack-plugin') | ||
const pkg = require('../package.json') | ||
const WebpackNotifierPlugin = require('webpack-notifier') | ||
|
||
Object.keys(baseWebpackConfig.entry).forEach(function (name) { | ||
baseWebpackConfig.entry[name] = ['./.config/dev-client'].concat(baseWebpackConfig.entry[name]) | ||
}) | ||
|
||
module.exports = merge(baseWebpackConfig, { | ||
module: { | ||
loaders: utils.styleLoaders({sourceMap: config.dev.cssSourceMap}) | ||
}, | ||
devtool: '#eval-source-map', | ||
plugins: [ | ||
new WebpackNotifierPlugin({ | ||
title: `${pkg.name}@${pkg.version}`, | ||
excludeWarnings: true, | ||
contentImage: `${__dirname}/logo.png` | ||
}), | ||
new webpack.DefinePlugin({ | ||
'process.env': config.dev.env | ||
}), | ||
new webpack.optimize.OccurenceOrderPlugin(), | ||
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.NoErrorsPlugin(), | ||
new HtmlWebpackPlugin({ | ||
filename: 'index.html', | ||
template: 'index.html', | ||
inject: true | ||
}) | ||
] | ||
}) |
Oops, something went wrong.