From dcf3291623d9fe54bcbf0ca48c0ed35865b8871a Mon Sep 17 00:00:00 2001 From: euvl Date: Tue, 20 Jun 2017 03:39:15 +0100 Subject: [PATCH] Added putputs for client and server --- build/webpack.base.config.js | 41 ++ build/webpack.client.config.js | 10 + build/webpack.server.config.js | 11 + demo/webpack.config.js | 2 +- dist/client.index.js | 1 + dist/index.js | 993 --------------------------------- dist/ssr.index.js | 1 + package.json | 15 +- webpack.config.js | 60 -- 9 files changed, 74 insertions(+), 1060 deletions(-) create mode 100644 build/webpack.base.config.js create mode 100644 build/webpack.client.config.js create mode 100644 build/webpack.server.config.js create mode 100644 dist/client.index.js delete mode 100644 dist/index.js create mode 100644 dist/ssr.index.js delete mode 100644 webpack.config.js diff --git a/build/webpack.base.config.js b/build/webpack.base.config.js new file mode 100644 index 0000000..6fdc4b9 --- /dev/null +++ b/build/webpack.base.config.js @@ -0,0 +1,41 @@ +const path = require('path') +const webpack = require('webpack') +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); + +// "build:client": "cross-env NODE_ENV=production webpack --config ./build/webpack.client.config.js --progress --hide-modules", + +module.exports = { + entry: path.resolve(__dirname, '../src/index.js'), + output: { + path: path.resolve(__dirname, '../dist'), + publicPath: '/dist/', + filename: 'index.js', + library:'VueJsModal', + libraryTarget: 'commonjs2' + }, + module: { + rules: [ + { + test: /\.vue$/, + loader: 'vue-loader' + }, + { + test: /\.js$/, + loader: 'babel-loader', + exclude: /node_modules/ + } + ] + }, + externals: { + vue: 'vue' + }, + resolve: { + alias: { + 'vue$': 'vue/dist/vue.esm.js' + } + }, + devtool: '#source-map', + plugins: [ + new UglifyJSPlugin() + ] +} diff --git a/build/webpack.client.config.js b/build/webpack.client.config.js new file mode 100644 index 0000000..a4f0580 --- /dev/null +++ b/build/webpack.client.config.js @@ -0,0 +1,10 @@ +const path = require('path') +const webpack = require('webpack') +const merge = require('webpack-merge') +const base = require('./webpack.base.config') + +module.exports = merge(base, { + output: { + filename: 'client.index.js' + } +}) diff --git a/build/webpack.server.config.js b/build/webpack.server.config.js new file mode 100644 index 0000000..c1b256e --- /dev/null +++ b/build/webpack.server.config.js @@ -0,0 +1,11 @@ +const path = require('path') +const webpack = require('webpack') +const merge = require('webpack-merge') +const base = require('./webpack.base.config') + +module.exports = merge(base, { + target: 'node', + output: { + filename: 'ssr.index.js' + } +}) diff --git a/demo/webpack.config.js b/demo/webpack.config.js index 5cb1efb..9237e73 100644 --- a/demo/webpack.config.js +++ b/demo/webpack.config.js @@ -37,7 +37,7 @@ module.exports = { resolve: { alias: { 'vue$': 'vue/dist/vue.esm.js', - 'plugin': path.resolve(__dirname, "../dist/index.js") + 'plugin': path.resolve(__dirname, "../dist/client.index.js") } }, devServer: { diff --git a/dist/client.index.js b/dist/client.index.js new file mode 100644 index 0000000..3c85f8f --- /dev/null +++ b/dist/client.index.js @@ -0,0 +1 @@ +module.exports=function(e){function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="/dist/",n(n.s=0)}([function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t(5),o=function(e){return e&&e.__esModule?e:{default:e}}(i),a={install:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.hasOwnProperty("event")||(this.event=new e);var n={show:function(e,n){a.event.$emit("toggle",e,!0,n)},hide:function(e,n){a.event.$emit("toggle",e,!1,n)},toggle:function(e,n){a.event.$emit("toggle",e,void 0,n)}};return Object.defineProperty(e.prototype,"$modal",{get:function(){return n}}),e.component("modal",o.default),null}};n.default=a},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.inRange=function(e,n,t){return tn?n:t}},function(e,n){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],n=0;nt.parts.length&&(i.parts.length=t.parts.length)}else{for(var s=[],o=0;o=0}},minHeight:{type:Number,default:0,validator:function(e){return e>=0}},adaptiveMaxWidth:{type:Number,default:1,validator:function(e){return e>0&&e<=1}},adaptiveMaxHeight:{type:Number,default:1,validator:function(e){return e>0&&e<=1}},width:{type:Number,default:600,validator:function(e){return e>=0}},height:{type:[Number,String],default:300,validator:function(e){return"string"==typeof e?"auto"===e:"number"==typeof e?e>=0:void 0}},pivotX:{type:Number,default:.5,validator:function(e){return e>=0&&e<=1}},pivotY:{type:Number,default:.5,validator:function(e){return e>=0&&e<=1}}},components:{Resizer:d.default},data:function(){return{visible:!1,visibility:{modal:!1,overlay:!1},shift:{left:0,top:0},modal:{width:this.width,height:this.height},window:{width:0,height:0},draggableElement:!1}},watch:{visible:function(e){var n=this;e?(this.visibility.overlay=!0,this.adaptSize(),setTimeout(function(){n.visibility.modal=!0,n.$nextTick(function(){n.addDraggableListeners()})},this.delay)):(this.visibility.modal=!1,setTimeout(function(){n.visibility.overlay=!1,n.$nextTick(function(){n.removeDraggableListeners()})},this.delay))}},beforeMount:function(){var e=this;r.default.event.$on("toggle",function(n,t,i){n===e.name&&(void 0===t&&(t=!e.visible),e.toggle(t,i))}),window.addEventListener("resize",this.onWindowResize),this.onWindowResize()},beforeDestroy:function(){window.removeEventListener("resize",this.onWindowResize)},computed:{position:function(){var e=this.window,n=this.modal,t=this.shift,i=e.width-n.width,o=e.height-n.height,a=t.left+this.pivotX*(e.width-n.width),s=t.top+this.pivotY*(e.height-n.height);return{left:(0,u.inRange)(0,i,a),top:(0,u.inRange)(0,o,s)}},modalClass:function(){return["v--modal-box",this.classes]},modalStyle:function(){return{top:this.position.top+"px",left:this.position.left+"px",width:this.modal.width+"px",height:this.modal.height+"px"}}},methods:{onWindowResize:function(){this.window.width=window.innerWidth,this.window.height=window.innerHeight,this.adaptSize()},genEventObject:function(e){var n={name:this.name,timestamp:Date.now(),canceled:!1,ref:this.$refs.modal,stop:function(){this.canceled=!0}};return a.default.util.extend(n,e||{})},adaptSize:function(){this.adaptive&&(this.modal.width=(0,u.inRange)(0,this.window.width*this.maxAdaptiveWidth,this.modal.width),this.modal.height=(0,u.inRange)(0,this.window.height*this.maxAdaptiveWidth,this.modal.height))},resize:function(e){this.modal.width=e.size.width,this.modal.height=e.size.height;var n=this.modal.size,t=this.genEventObject({size:n});this.$emit("resize",t)},toggle:function(e,n){var t=this.visible?"before-close":"before-open",i=this.visible?"closed":"opened",o=!1,a=function(){o=!0},s=this.genEventObject({stop:a,state:e,params:n});if(this.$emit(t,s),!o){var r=this.genEventObject({state:e,params:n});this.visible=e,this.$emit(i,r)}},emitCancelableEvent:function(e){this.genEventObject(e)},getDraggableElement:function(){var e="string"!=typeof this.draggable?".v--modal-box":this.draggable;if(e){var n=this.$refs.overlay.querySelector(e);if(n)return n}},addDraggableListeners:function(){var e=this;if(this.draggable){var n=this.getDraggableElement();if(n){var t=0,i=0,o=0,a=0,s=function(e){return e.touches&&e.touches.length>0?e.touches[0]:e},r=function(n){var r=s(n),u=r.clientX,h=r.clientY;document.addEventListener("mousemove",l),document.addEventListener("mouseup",d),document.addEventListener("touchmove",l),document.addEventListener("touchend",d),t=u,i=h,o=e.shift.left,a=e.shift.top,n.preventDefault()},l=function(n){var r=s(n),l=r.clientX,d=r.clientY;e.shift.left=o+l-t,e.shift.top=a+d-i,n.preventDefault()},d=function e(n){document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",e),document.removeEventListener("touchmove",l),document.removeEventListener("touchend",e),n.preventDefault()};n.addEventListener("mousedown",r),n.addEventListener("touchstart",r)}}},removeDraggableListeners:function(){}}}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t(1);n.default={name:"VueJsModalResizer",props:{minHeight:{type:Number,default:0},minWidth:{type:Number,default:0}},data:function(){return{clicked:!1,size:{}}},mounted:function(){this.$el.addEventListener("mousedown",this.start,!1)},computed:{className:function(){return{"vue-modal-resizer":!0,clicked:this.clicked}}},methods:{start:function(e){this.clicked=!0,window.addEventListener("mousemove",this.mousemove,!1),window.addEventListener("mouseup",this.stop,!1),e.stopPropagation(),e.preventDefault()},stop:function(){this.clicked=!1,window.removeEventListener("mousemove",this.mousemove,!1),window.removeEventListener("mouseup",this.stop,!1),this.$emit("resize-stop",{element:this.$el.parentElement,size:this.size})},mousemove:function(e){this.resize(e)},resize:function(e){var n=this.$el.parentElement;if(n){var t=e.clientX-n.offsetLeft,o=e.clientY-n.offsetTop;t=(0,i.inRange)(this.minWidth,window.innerWidth,t),o=(0,i.inRange)(this.minHeight,window.innerHeight,o),this.size={width:t,height:o},n.style.width=t+"px",n.style.height=o+"px",this.$emit("resize",{element:n,size:this.size})}}}}},function(e,n,t){n=e.exports=t(2)(),n.push([e.i,"\n.v--modal-overlay {\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(0, 0, 0, 0.2);\n z-index: 999;\n opacity: 1;\n}\n.v--modal-overlay .v--modal-box {\n position: relative;\n overflow: hidden;\n box-sizing: border-box;\n background-color: white;\n}\n.v--modal {\n background: white;\n text-align: left;\n border-radius: 3px;\n box-shadow: 0 20px 60px -2px rgba(27, 33, 58, .4);\n padding: 0;\n}\n.v--modal.v--modal-fullscreen {\n width: 100vw;\n height: 100vh;\n margin: 0;\n left: 0;\n top: 0;\n}\n.v--modal-top-right {\n display: block;\n position: absolute;\n right: 0;\n top: 0;\n}\n.overlay-fade-enter-active, .overlay-fade-leave-active {\n transition: all 0.2s;\n}\n.overlay-fade-enter, .overlay-fade-leave-active {\n opacity: 0;\n}\n.nice-modal-fade-enter-active, .nice-modal-fade-leave-active {\n transition: all 0.4s;\n}\n.nice-modal-fade-enter, .nice-modal-fade-leave-active {\n opacity: 0;\n transform: translateY(-20px);\n}\n","",{version:3,sources:["/./src/Modal.vue?0a9916d5"],names:[],mappings:";AAsXA;EACA,gBAAA;EACA,QAAA;EACA,OAAA;EACA,aAAA;EACA,cAAA;EACA,+BAAA;EACA,aAAA;EACA,WAAA;CACA;AAEA;EACA,mBAAA;EACA,iBAAA;EACA,uBAAA;EACA,wBAAA;CACA;AAEA;EACA,kBAAA;EACA,iBAAA;EACA,mBAAA;EACA,kDAAA;EACA,WAAA;CACA;AAEA;EACA,aAAA;EACA,cAAA;EACA,UAAA;EACA,QAAA;EACA,OAAA;CACA;AAEA;EACA,eAAA;EACA,mBAAA;EACA,SAAA;EACA,OAAA;CACA;AAEA;EACA,qBAAA;CACA;AAEA;EACA,WAAA;CACA;AAEA;EACA,qBAAA;CACA;AAEA;EACA,WAAA;EACA,6BAAA;CACA",file:"Modal.vue",sourcesContent:["\n