From 107f3b12fb3e42c602dc273ea89ad24b14d5ac36 Mon Sep 17 00:00:00 2001 From: Vincent Gabriel Date: Tue, 15 Jan 2019 11:11:32 -0800 Subject: [PATCH] upgraded dev dependencies; Webpack 4 --- .babelrc | 14 +- .eslintrc.json | 44 + build/webpack.config.js | 36 +- demo/src/main.js | 8 +- demo/src/main.vue | 52 +- demo/webpack.config.js | 59 +- dist/index.js | 454 +----- package.json | 41 +- src/index.js | 8 +- src/webcam.vue | 80 +- yarn.lock | 3185 ++++++++++++++++++++++++++------------- 11 files changed, 2341 insertions(+), 1640 deletions(-) create mode 100644 .eslintrc.json diff --git a/.babelrc b/.babelrc index 543e0ab..a842e5e 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,11 @@ { - "presets": ["es2015", "stage-2"], - "plugins": [], - "comments": false -} + "presets": [ + ["@babel/preset-env", { "modules": false } ] + ], + "plugins": [ + "@babel/plugin-syntax-dynamic-import", + "@babel/plugin-transform-runtime", + "@babel/plugin-transform-object-assign", + "@babel/plugin-proposal-object-rest-spread" + ] +} \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..8dfc842 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,44 @@ +{ + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true + }, + "extends": [ + "eslint:recommended", + "plugin:vue/recommended", + "plugin:import/errors", + "plugin:import/warnings" + ], + "parserOptions": { + "parser": "babel-eslint", + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 2017, + "sourceType": "module" + }, + "plugins": ["vue", "prettier"], + "rules": { + "no-const-assign": "warn", + "no-this-before-super": "warn", + "no-undef": "warn", + "no-unreachable": "warn", + "no-unused-vars": "off", + "constructor-super": "warn", + "valid-typeof": "warn", + "import/no-unresolved": "off", + "import/no-unassigned-import": "warn", + "semi": 0, + "no-console": "off", + "prettier/prettier": "error", + "vue/max-attributes-per-line": [2, { + "singleline": 2, + "multiline": { + "max": 1, + "allowFirstLine": true + } + }] + } + } \ No newline at end of file diff --git a/build/webpack.config.js b/build/webpack.config.js index 9f23022..b7c7340 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -1,42 +1,42 @@ -var path = require('path') -var webpack = require('webpack') -const VueLoaderPlugin = require('vue-loader/lib/plugin') +var path = require("path"); +var webpack = require("webpack"); +const VueLoaderPlugin = require("vue-loader/lib/plugin"); module.exports = { - entry: './src/index.js', + entry: "./src/index.js", output: { - path: path.resolve(__dirname, '../dist'), - publicPath: '/dist/', - filename: 'index.js', - library:'vue-web-cam', - libraryTarget: 'umd' + path: path.resolve(__dirname, "../dist"), + publicPath: "/dist/", + filename: "index.js", + library: "vue-web-cam", + libraryTarget: "umd" }, module: { rules: [ { test: /\.vue$/, - loader: 'vue-loader', + loader: "vue-loader", options: { loaders: { - 'scss': 'vue-style-loader!css-loader!sass-loader', - 'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax' + scss: "vue-style-loader!css-loader!sass-loader", + sass: "vue-style-loader!css-loader!sass-loader?indentedSyntax" } } }, { test: /\.js$/, - loader: 'babel-loader', + loader: "babel-loader", exclude: /node_modules/ } ] }, externals: { - vue: 'vue' + vue: "vue" }, resolve: { - extensions: ['.js', '.vue'], + extensions: [".js", ".vue"], alias: { - 'vue': 'vue/dist/vue.esm.js' + vue: "vue/dist/vue.esm.js" } }, devServer: { @@ -49,7 +49,7 @@ module.exports = { plugins: [ new VueLoaderPlugin(), new webpack.DefinePlugin({ - 'process.env': { + "process.env": { NODE_ENV: '"production"' } }), @@ -57,4 +57,4 @@ module.exports = { minimize: true }) ] -} \ No newline at end of file +}; diff --git a/demo/src/main.js b/demo/src/main.js index 548587a..7da279a 100644 --- a/demo/src/main.js +++ b/demo/src/main.js @@ -1,10 +1,10 @@ -import Vue from 'vue' -import App from './main.vue' +import Vue from "vue"; +import App from "./main.vue"; // import WebCam from 'plugin' // Vue.use(WebCam) new Vue({ - el: '#app', + el: "#app", render: h => h(App) -}) +}); diff --git a/demo/src/main.vue b/demo/src/main.vue index 24a02fd..f51aca9 100644 --- a/demo/src/main.vue +++ b/demo/src/main.vue @@ -6,33 +6,41 @@ {{ device.label }}
+ :device-id="deviceId" + width="100%" + @started="onStarted" + @stopped="onStopped" + @error="onError" + @cameras="onCameras" + @camera-change="onCameraChange" />
- - - + + +

Captured Image

- +
@@ -40,10 +48,10 @@