Skip to content

Commit 2978508

Browse files
author
Rowan Winsemius
committed
initial commit
1 parent e8faa80 commit 2978508

28 files changed

+925
-0
lines changed

.babelrc

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

+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

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

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log
5+
selenium-debug.log
6+
test/unit/coverage
7+
test/e2e/reports

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# vue-dropzone
2+
3+
> A Vue component for file uploads, powered by Dropzone.js
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+
# run unit tests
18+
npm run unit
19+
20+
# run e2e tests
21+
npm run e2e
22+
23+
# run all tests
24+
npm test
25+
```
26+
27+
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+
// https://github.com/shelljs/shelljs
2+
require('shelljs/global')
3+
env.NODE_ENV = 'production'
4+
5+
var path = require('path')
6+
var config = require('../config')
7+
var ora = require('ora')
8+
var webpack = require('webpack')
9+
var webpackConfig = require('./webpack.prod.conf')
10+
11+
console.log(
12+
' Tip:\n' +
13+
' Built files are meant to be served over an HTTP server.\n' +
14+
' Opening index.html over file:// won\'t work.\n'
15+
)
16+
17+
var spinner = ora('building for production...')
18+
spinner.start()
19+
20+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
21+
rm('-rf', assetsPath)
22+
mkdir('-p', assetsPath)
23+
cp('-R', 'static/', assetsPath)
24+
25+
webpack(webpackConfig, function (err, stats) {
26+
spinner.stop()
27+
if (err) throw err
28+
process.stdout.write(stats.toString({
29+
colors: true,
30+
modules: false,
31+
children: false,
32+
chunks: false,
33+
chunkModules: false
34+
}) + '\n')
35+
})

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

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

build/utils.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
return path.posix.join(config.build.assetsSubDirectory, _path)
7+
}
8+
9+
exports.cssLoaders = function (options) {
10+
options = options || {}
11+
// generate loader string to be used with extract text plugin
12+
function generateLoaders (loaders) {
13+
var sourceLoader = loaders.map(function (loader) {
14+
var extraParamChar
15+
if (/\?/.test(loader)) {
16+
loader = loader.replace(/\?/, '-loader?')
17+
extraParamChar = '&'
18+
} else {
19+
loader = loader + '-loader'
20+
extraParamChar = '?'
21+
}
22+
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
23+
}).join('!')
24+
25+
if (options.extract) {
26+
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
27+
} else {
28+
return ['vue-style-loader', sourceLoader].join('!')
29+
}
30+
}
31+
32+
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
33+
return {
34+
css: generateLoaders(['css']),
35+
postcss: generateLoaders(['css']),
36+
less: generateLoaders(['css', 'less']),
37+
sass: generateLoaders(['css', 'sass?indentedSyntax']),
38+
scss: generateLoaders(['css', 'sass']),
39+
stylus: generateLoaders(['css', 'stylus']),
40+
styl: generateLoaders(['css', 'stylus'])
41+
}
42+
}
43+
44+
// Generate loaders for standalone style files (outside of .vue)
45+
exports.styleLoaders = function (options) {
46+
var output = []
47+
var loaders = exports.cssLoaders(options)
48+
for (var extension in loaders) {
49+
var loader = loaders[extension]
50+
output.push({
51+
test: new RegExp('\\.' + extension + '$'),
52+
loader: loader
53+
})
54+
}
55+
return output
56+
}

build/webpack.base.conf.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var utils = require('./utils')
4+
var projectRoot = path.resolve(__dirname, '../')
5+
6+
module.exports = {
7+
entry: {
8+
app: './example/main.js'
9+
},
10+
output: {
11+
path: config.build.assetsRoot,
12+
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
13+
filename: '[name].js'
14+
},
15+
resolve: {
16+
extensions: ['', '.js', '.vue'],
17+
fallback: [path.join(__dirname, '../node_modules')],
18+
alias: {
19+
'src': path.resolve(__dirname, '../src'),
20+
'assets': path.resolve(__dirname, '../src/assets'),
21+
'components': path.resolve(__dirname, '../src/components')
22+
}
23+
},
24+
resolveLoader: {
25+
fallback: [path.join(__dirname, '../node_modules')]
26+
},
27+
module: {
28+
loaders: [
29+
{
30+
test: /\.vue$/,
31+
loader: 'vue'
32+
},
33+
{
34+
test: /\.js$/,
35+
loader: 'babel',
36+
include: projectRoot,
37+
exclude: /node_modules/
38+
},
39+
{
40+
test: /\.json$/,
41+
loader: 'json'
42+
},
43+
{
44+
test: /\.html$/,
45+
loader: 'vue-html'
46+
},
47+
{
48+
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
49+
loader: 'url',
50+
query: {
51+
limit: 10000,
52+
name: utils.assetsPath('img/[name].[hash:7].[ext]')
53+
}
54+
},
55+
{
56+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
57+
loader: 'url',
58+
query: {
59+
limit: 10000,
60+
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
61+
}
62+
}
63+
]
64+
},
65+
vue: {
66+
loaders: utils.cssLoaders()
67+
}
68+
}

build/webpack.dev.conf.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var config = require('../config')
2+
var webpack = require('webpack')
3+
var merge = require('webpack-merge')
4+
var utils = require('./utils')
5+
var baseWebpackConfig = require('./webpack.base.conf')
6+
var HtmlWebpackPlugin = require('html-webpack-plugin')
7+
8+
// add hot-reload related code to entry chunks
9+
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
10+
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
11+
})
12+
13+
module.exports = merge(baseWebpackConfig, {
14+
module: {
15+
loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
16+
},
17+
// eval-source-map is faster for development
18+
devtool: '#eval-source-map',
19+
plugins: [
20+
new webpack.DefinePlugin({
21+
'process.env': config.dev.env
22+
}),
23+
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
24+
new webpack.optimize.OccurenceOrderPlugin(),
25+
new webpack.HotModuleReplacementPlugin(),
26+
new webpack.NoErrorsPlugin(),
27+
// https://github.com/ampedandwired/html-webpack-plugin
28+
new HtmlWebpackPlugin({
29+
filename: 'index.html',
30+
template: 'index.html',
31+
inject: true
32+
})
33+
]
34+
})

0 commit comments

Comments
 (0)