Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Commit

Permalink
make build
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Nov 11, 2016
1 parent 4450de3 commit d922448
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"comments": false
}
40 changes: 40 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = {
root: true,
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jquery": false,
mocha: true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"plugins": [
"html"
],
"rules": {
"indent": [
"warn",
"tab"
],
"quotes": [
"warn",
"double"
],
"semi": [
"error",
"always"
],
"no-var": [
"error"
],
"no-console": [
"off"
],
"no-unused-vars": [
"warn"
]
}
};
46 changes: 9 additions & 37 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
.DS_Store
node_modules/
coverage/
docs/_book/
npm-debug.log
selenium-debug.log
test/unit/coverage
test/e2e/reports
stats.json
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
docs
bower.json
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: node_js
cache:
directories:
- node_modules
node_js:
- "6"
- "5"
- "4"
after_success:
- npm run coverall
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# vue-websocket
Websocket plugin for VueJS. Support namespaces.

## Install
### NPM
You can install it via [NPM](http://npmjs.org/).
```
$ npm install vue-websocket
```
### Manual
Download zip package and unpack and add the `vue-websocket.js` file to your project from dist folder.
```
https://github.com/icebob/vue-websocket/archive/master.zip
```

## Usage
Register the plugin
```js
Expand Down Expand Up @@ -60,3 +72,26 @@ Use it in your components:
</script>
```

## Build
This command will build a distributable version in the `dist` directory.
```bash
npm run build
```

## Test
```bash
npm test
```

## Contribution
Please send pull requests improving the usage and fixing bugs, improving documentation and providing better examples, or providing some testing, because these things are important.

## License
vue-touch-keyboard is available under the [MIT license](https://tldrlegal.com/license/mit-license).

## Contact

Copyright (C) 2016 Icebob

[![@icebob](https://img.shields.io/badge/github-icebob-green.svg)](https://github.com/icebob) [![@icebob](https://img.shields.io/badge/twitter-Icebobcsi-blue.svg)](https://twitter.com/Icebobcsi)
4 changes: 4 additions & 0 deletions dist/vue-websocket.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/vue-websocket.js.map

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"name": "vue-websocket",
"version": "0.1.0",
"description": "Websocket handler for Vue.js",
"homepage": "https://github.com/icebob/vue-websocket",
"main": "dist/vue-websocket.js",
"scripts": {
"_prebuild": "npm run test",
"build": "webpack --progress -p --hide-modules --config webpack.build.config.js",
"lint": "eslint --ext=.js,.vue src test/unit/specs",
"coverall": "cat ./test/unit/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"coverage": "npm run test && npm run coverall",
"changelog": "conventional-changelog -i CHANGELOG.md -s",
"unit": "karma start test/unit/karma.conf.js",
"pretest": "npm run lint",
"test": "npm run unit",
"ci": "karma start test/unit/karma.conf.js --auto-watch --no-single-run --reporters=dots --port=9877"
},
"keywords": [
"vue",
"websocket",
"socket",
"socket.io"
],
"repository": {
"type": "git",
"url": "https://github.com/icebob/vue-websocket.git"
},
"files": [
"dist",
"src"
],
"author": "Icebob",
"license": "MIT",
"devDependencies": {
"babel-core": "6.14.0",
"babel-loader": "6.2.5",
"babel-plugin-transform-runtime": "6.15.0",
"babel-preset-es2015": "6.14.0",
"babel-preset-stage-2": "6.5.0",
"chai": "3.5.0",
"conventional-changelog-cli": "1.2.0",
"coveralls": "2.11.14",
"eslint": "3.6.1",
"eslint-friendly-formatter": "2.0.6",
"eslint-loader": "1.5.0",
"eslint-plugin-html": "1.5.3",
"eslint-plugin-vue": "0.1.1",
"isparta-loader": "2.0.0",
"karma": "1.3.0",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "1.0.1",
"karma-coverage": "1.1.1",
"karma-coveralls": "1.1.2",
"karma-mocha": "1.2.0",
"karma-phantomjs-launcher": "1.0.2",
"karma-sinon-chai": "1.2.4",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "1.8.0",
"lodash": "4.16.2",
"lolex": "1.5.1",
"mocha": "2.5.3",
"mocha-generators": "1.2.0",
"mocha-loader": "0.7.1",
"phantomjs-prebuilt": "2.1.12",
"sinon": "1.17.6",
"sinon-chai": "2.8.0",
"vue-hot-reload-api": "1.3.2",
"vue-loader": "8.5.4",
"webpack": "1.13.2",
"webpack-dev-middleware": "1.8.3",
"webpack-dev-server": "1.16.1",
"webpack-merge": "0.14.1"
},
"dependencies": {
"babel-runtime": "6.11.6",
"socket.io-client": "1.5.1",
"vue": "1.0.27"
}
}
11 changes: 5 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Vue from "vue";
import IO from "socket.io-client";

export default {
Expand All @@ -16,7 +15,7 @@ export default {

let addListeners = function() {
if (this.$options.hasOwnProperty("socket")) {
var conf = this.$options.socket;
let conf = this.$options.socket;
if (conf.namespace) {
this.$socket = IO(conf.namespace, conf.options);
}
Expand All @@ -30,11 +29,11 @@ export default {
});
}
}
}
};

let removeListeners = function() {
if (this.$options.hasOwnProperty("socket")) {
var conf = this.$options.socket;
let conf = this.$options.socket;

if (conf.namespace) {
this.$socket.disconnect();
Expand All @@ -47,7 +46,7 @@ export default {
});
}
}
}
};

Vue.mixin({
beforeCompile: addListeners,
Expand All @@ -56,4 +55,4 @@ export default {

}

}
};
48 changes: 48 additions & 0 deletions webpack.build.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
var webpack = require("webpack");
var version = require("./package.json").version;
var banner = "/**\n" + " * vue-websocket v" + version + "\n" + " * https://github.com/icebob/vue-websocket\n" + " * Released under the MIT License.\n" + " */\n";

module.exports = [
{
devtool: "source-map",
entry: "./src/index",
output: {
path: "./dist",
filename: "vue-websocket.js",
library: "VueWebsocket",
libraryTarget: "umd"
},

plugins: [
new webpack.DefinePlugin({
"process.env" : {
NODE_ENV : JSON.stringify("production")
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.BannerPlugin(banner, {
raw: true
})
],

module: {
loaders: [
{
"test": /\.js?$/,
"exclude": /node_modules/,
"loader": "babel"
},
{
"test": /\.vue$/,
"loader": "vue"
}
]
}
}

];
33 changes: 33 additions & 0 deletions webpack.dev.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var path = require("path");
var webpack = require("webpack");

module.exports = {
devtool: "eval-source-map",

entry: {
app: path.resolve("dev", "main.js")
},

output: {
path: path.resolve("dev"),
filename: "[name].js",
publicPath: "/"
},

plugins: [
],

module: {
loaders: [
{
"test": /\.js?$/,
"exclude": /node_modules/,
"loader": "babel"
},
{
"test": /\.vue?$/,
"loader": "vue"
}
]
}
};

0 comments on commit d922448

Please sign in to comment.