mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Refactored, added es5 build
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
*.map
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
import Vue from 'vue';
|
|
||||||
import Modal from './Modal.vue';
|
|
||||||
|
|
||||||
const VueModal = {
|
|
||||||
install(Vue, options = {}) {
|
|
||||||
if (!this.hasOwnProperty("event")) {
|
|
||||||
this.event = new Vue();
|
|
||||||
}
|
|
||||||
|
|
||||||
const $modal = {
|
|
||||||
show(name, params) {
|
|
||||||
VueModal.event.$emit('toggle', name, true, params);
|
|
||||||
},
|
|
||||||
hide(name, params) {
|
|
||||||
VueModal.event.$emit('toggle', name, false, params);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.defineProperty(Vue.prototype, '$modal', {
|
|
||||||
get: () => $modal
|
|
||||||
});
|
|
||||||
|
|
||||||
Vue.component('modal', Modal);
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
Vue.use(VueModal);
|
|
||||||
|
|
||||||
export default VueModal;
|
|
||||||
26
demo/package.json
Normal file
26
demo/package.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "demo",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
|
||||||
|
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"vue": "^2.0.0",
|
||||||
|
"vue-js-modal": "*"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-core": "^6.0.0",
|
||||||
|
"babel-loader": "^6.0.0",
|
||||||
|
"babel-preset-latest": "^6.0.0",
|
||||||
|
"cross-env": "^3.0.0",
|
||||||
|
"css-loader": "^0.25.0",
|
||||||
|
"file-loader": "^0.9.0",
|
||||||
|
"node-sass": "^4.5.0",
|
||||||
|
"sass-loader": "^5.0.1",
|
||||||
|
"vue-loader": "^11.1.4",
|
||||||
|
"vue-template-compiler": "^2.2.1",
|
||||||
|
"webpack": "^2.2.0",
|
||||||
|
"webpack-dev-server": "^2.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -134,9 +134,9 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
show(resizable, adaptive) {
|
show(resizable, adaptive) {
|
||||||
this.resizable = resizable;
|
this.resizable = resizable
|
||||||
this.adaptive = adaptive;
|
this.adaptive = adaptive
|
||||||
this.$modal.show('example-modal');
|
this.$modal.show('example-modal')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
8
demo/src/main.js
Normal file
8
demo/src/main.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import App from './App.vue'
|
||||||
|
import Modal from 'vue-js-modal'
|
||||||
|
|
||||||
|
new Vue({
|
||||||
|
el: '#app',
|
||||||
|
render: h => h(App)
|
||||||
|
})
|
||||||
75
demo/webpack.config.js
Normal file
75
demo/webpack.config.js
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
var path = require('path')
|
||||||
|
var webpack = require('webpack')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: './src/main.js',
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, './dist'),
|
||||||
|
publicPath: '/dist/',
|
||||||
|
filename: 'build.js'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.vue$/,
|
||||||
|
loader: 'vue-loader',
|
||||||
|
options: {
|
||||||
|
loaders: {
|
||||||
|
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
|
||||||
|
// the "scss" and "sass" values for the lang attribute to the right configs here.
|
||||||
|
// other preprocessors should work out of the box, no loader config like this necessary.
|
||||||
|
'scss': 'vue-style-loader!css-loader!sass-loader',
|
||||||
|
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
|
||||||
|
}
|
||||||
|
// other vue-loader options go here
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
loader: 'babel-loader',
|
||||||
|
exclude: /node_modules/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(png|jpg|gif|svg)$/,
|
||||||
|
loader: 'file-loader',
|
||||||
|
options: {
|
||||||
|
name: '[name].[ext]?[hash]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'vue$': 'vue/dist/vue.esm.js'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
devServer: {
|
||||||
|
historyApiFallback: true,
|
||||||
|
noInfo: true
|
||||||
|
},
|
||||||
|
performance: {
|
||||||
|
hints: false
|
||||||
|
},
|
||||||
|
devtool: '#eval-source-map'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
module.exports.devtool = '#source-map'
|
||||||
|
// http://vue-loader.vuejs.org/en/workflow/production.html
|
||||||
|
module.exports.plugins = (module.exports.plugins || []).concat([
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': {
|
||||||
|
NODE_ENV: '"production"'
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
|
sourceMap: true,
|
||||||
|
compress: {
|
||||||
|
warnings: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
new webpack.LoaderOptionsPlugin({
|
||||||
|
minimize: true
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
10340
dist/index.js
vendored
Normal file
10340
dist/index.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
|||||||
import Vue from 'vue';
|
|
||||||
import App from './App.vue';
|
|
||||||
import Modal from '../../Modal';
|
|
||||||
|
|
||||||
new Vue({
|
|
||||||
el: '#app',
|
|
||||||
render: h => h(App)
|
|
||||||
});
|
|
||||||
13
package.json
13
package.json
@@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-js-modal",
|
"name": "vue-js-modal",
|
||||||
"description": "Modal Component for Vue.js",
|
"description": "Modal Component for Vue.js",
|
||||||
"version": "1.0.3",
|
"version": "1.0.10",
|
||||||
"author": "euvl <yev.vlasenko@gmail.com>",
|
"author": "euvl <yev.vlasenko@gmail.com>",
|
||||||
"private": false,
|
"main": "dist/index.js",
|
||||||
"main": "./Modal/index.js",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/euvl/vue-js-modal.git"
|
"url": "https://github.com/euvl/vue-js-modal.git"
|
||||||
@@ -17,10 +16,11 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/euvl/vue-js-modal/issues"
|
"url": "https://github.com/euvl/vue-js-modal/issues"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"examples": "cross-env NODE_ENV=development webpack-dev-server --open --hot"
|
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
|
||||||
|
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
|
||||||
},
|
},
|
||||||
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vue": "^2.1.10",
|
"vue": "^2.1.10",
|
||||||
"babel-core": "^6.0.0",
|
"babel-core": "^6.0.0",
|
||||||
@@ -37,5 +37,8 @@
|
|||||||
"vue-template-compiler": "^2.1.0",
|
"vue-template-compiler": "^2.1.0",
|
||||||
"webpack": "^2.2.0",
|
"webpack": "^2.2.0",
|
||||||
"webpack-dev-server": "^2.2.0"
|
"webpack-dev-server": "^2.2.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"vue": "^2.2.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
@mousedown.stop="toggle(false)">
|
@mousedown.stop="toggle(false)">
|
||||||
<transition :name="transition">
|
<transition :name="transition">
|
||||||
<div v-if="visibility.modal"
|
<div v-if="visibility.modal"
|
||||||
v-bind:class="modalClass"
|
ref="modal"
|
||||||
v-bind:style="modalStyle"
|
:class="modalClass"
|
||||||
v-on:mousedown.stop
|
:style="modalStyle"
|
||||||
ref="modal">
|
@mousedown.stop>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<resizer v-if="resizable"
|
<resizer v-if="resizable"
|
||||||
:min-width="minWidth"
|
:min-width="minWidth"
|
||||||
@@ -20,9 +20,9 @@
|
|||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue';
|
import Vue from 'vue'
|
||||||
import Modal from './index';
|
import Modal from './index'
|
||||||
import Resizer from './Resizer.vue';
|
import Resizer from './Resizer.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Modal',
|
name: 'Modal',
|
||||||
@@ -94,26 +94,26 @@
|
|||||||
visible(value) {
|
visible(value) {
|
||||||
if (this.delay > 0) {
|
if (this.delay > 0) {
|
||||||
if (value) {
|
if (value) {
|
||||||
this.visibility.overlay = true;
|
this.visibility.overlay = true
|
||||||
setTimeout(() => this.visibility.modal = true, this.delay);
|
setTimeout(() => this.visibility.modal = true, this.delay)
|
||||||
} else {
|
} else {
|
||||||
this.visibility.modal = false;
|
this.visibility.modal = false
|
||||||
setTimeout(() => this.visibility.overlay = false, this.delay);
|
setTimeout(() => this.visibility.overlay = false, this.delay)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.visibility.overlay = value;
|
this.visibility.overlay = value
|
||||||
Vue.nextTick(() => this.visibility.modal = value);
|
Vue.nextTick(() => this.visibility.modal = value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
Modal.event.$on('toggle', (name, state, params) => {
|
Modal.event.$on('toggle', (name, state, params) => {
|
||||||
if (name === this.name) {
|
if (name === this.name) {
|
||||||
this.toggle(!this.visible, params);
|
this.toggle(!this.visible, params)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('resize', this.onWindowResize);
|
window.addEventListener('resize', this.onWindowResize)
|
||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
this.onWindowResize();
|
this.onWindowResize();
|
||||||
@@ -121,12 +121,12 @@
|
|||||||
computed: {
|
computed: {
|
||||||
position() {
|
position() {
|
||||||
return {
|
return {
|
||||||
left: Math.max((this.window.width - this.modal.width) / 2, 0),
|
left: Math.max(0.5 * (this.window.width - this.modal.width), 0),
|
||||||
top: Math.max((this.window.height - this.modal.height) / 2, 0)
|
top: Math.max(0.5 * (this.window.height - this.modal.height), 0)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modalClass() {
|
modalClass() {
|
||||||
return ['modal', this.classes];
|
return ['modal', this.classes]
|
||||||
},
|
},
|
||||||
modalStyle() {
|
modalStyle() {
|
||||||
return {
|
return {
|
||||||
@@ -139,8 +139,8 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onWindowResize() {
|
onWindowResize() {
|
||||||
this.window.width = window.innerWidth;
|
this.window.width = window.innerWidth
|
||||||
this.window.height = window.innerHeight;
|
this.window.height = window.innerHeight
|
||||||
|
|
||||||
if (this.adaptive) {
|
if (this.adaptive) {
|
||||||
var width = this.window.width > this.modal.width
|
var width = this.window.width > this.modal.width
|
||||||
@@ -149,10 +149,10 @@
|
|||||||
|
|
||||||
var height = this.window.height > this.modal.height
|
var height = this.window.height > this.modal.height
|
||||||
? this.modal.height
|
? this.modal.height
|
||||||
: this.window.height;
|
: this.window.height
|
||||||
|
|
||||||
this.modal.width = width;//Math.max(width, this.minWidth);
|
this.modal.width = width // Math.max(width, this.minWidth);
|
||||||
this.modal.height = height;//Math.max(height, this.minHeight);
|
this.modal.height = height // Math.max(height, this.minHeight);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
genEventObject(params) {
|
genEventObject(params) {
|
||||||
@@ -165,38 +165,38 @@
|
|||||||
params || {});
|
params || {});
|
||||||
},
|
},
|
||||||
resize(event) {
|
resize(event) {
|
||||||
this.modal.width = event.size.width;
|
this.modal.width = event.size.width
|
||||||
this.modal.height = event.size.height;
|
this.modal.height = event.size.height
|
||||||
|
|
||||||
let resizeEvent = this.genEventObject({
|
let resizeEvent = this.genEventObject({
|
||||||
size: this.modal
|
size: this.modal
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$emit('resize', resizeEvent);
|
this.$emit('resize', resizeEvent)
|
||||||
},
|
},
|
||||||
toggle(state, params) {
|
toggle(state, params) {
|
||||||
const beforeEventName = this.visible ? 'before-close' : 'before-open';
|
const beforeEventName = this.visible ? 'before-close' : 'before-open'
|
||||||
const afterEventName = this.visible ? 'closed' : 'opened';
|
const afterEventName = this.visible ? 'closed' : 'opened'
|
||||||
|
|
||||||
let stopEventExecution = false;
|
let stopEventExecution = false
|
||||||
|
|
||||||
const beforeEvent = this.genEventObject({
|
const beforeEvent = this.genEventObject({
|
||||||
stop: () => stopEventExecution = false,
|
stop: () => stopEventExecution = false,
|
||||||
state,
|
state,
|
||||||
params
|
params
|
||||||
});
|
})
|
||||||
|
|
||||||
this.$emit(beforeEventName, beforeEvent);
|
this.$emit(beforeEventName, beforeEvent)
|
||||||
|
|
||||||
if (!stopEventExecution) {
|
if (!stopEventExecution) {
|
||||||
this.visible = !!state;
|
this.visible = !!state
|
||||||
|
|
||||||
const afterEvent = this.genEventObject({
|
const afterEvent = this.genEventObject({
|
||||||
state,
|
state,
|
||||||
params
|
params
|
||||||
});
|
})
|
||||||
|
|
||||||
this.$emit(afterEventName, afterEvent);
|
this.$emit(afterEventName, afterEvent)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="{'vue-modal-resizer': true, 'clicked': clicked}">
|
<div :class="className"></div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
@@ -21,23 +20,28 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$el.addEventListener('mousedown', this.start, false);
|
this.$el.addEventListener('mousedown', this.start, false)
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
className () {
|
||||||
|
return {'vue-modal-resizer': true, 'clicked': this.clicked}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
start(event) {
|
start(event) {
|
||||||
this.clicked = true;
|
this.clicked = true
|
||||||
|
|
||||||
window.addEventListener('mousemove', this.mousemove, false);
|
window.addEventListener('mousemove', this.mousemove, false)
|
||||||
window.addEventListener('mouseup', this.stop, false);
|
window.addEventListener('mouseup', this.stop, false)
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation()
|
||||||
event.preventDefault();
|
event.preventDefault()
|
||||||
},
|
},
|
||||||
stop() {
|
stop() {
|
||||||
this.clicked = false;
|
this.clicked = false
|
||||||
|
|
||||||
window.removeEventListener('mousemove', this.mousemove, false);
|
window.removeEventListener('mousemove', this.mousemove, false)
|
||||||
window.removeEventListener('mouseup', this.stop, false);
|
window.removeEventListener('mouseup', this.stop, false)
|
||||||
|
|
||||||
this.$emit('resize-stop', {
|
this.$emit('resize-stop', {
|
||||||
element: this.$el.parentElement,
|
element: this.$el.parentElement,
|
||||||
@@ -45,40 +49,39 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
mousemove(event) {
|
mousemove(event) {
|
||||||
this.resize(event);
|
this.resize(event)
|
||||||
},
|
},
|
||||||
resize(event) {
|
resize(event) {
|
||||||
var el = this.$el.parentElement;
|
var el = this.$el.parentElement
|
||||||
|
|
||||||
if (el) {
|
if (el) {
|
||||||
var width = event.clientX - el.offsetLeft;
|
var width = event.clientX - el.offsetLeft
|
||||||
var height = event.clientY - el.offsetTop;
|
var height = event.clientY - el.offsetTop
|
||||||
|
|
||||||
|
|
||||||
if (width < this.minWidth) {
|
if (width < this.minWidth) {
|
||||||
width = this.minWidth;
|
width = this.minWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width > window.innerWidth) {
|
if (width > window.innerWidth) {
|
||||||
width = window.innerWidth;
|
width = window.innerWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height < this.minHeight) {
|
if (height < this.minHeight) {
|
||||||
height = this.minHeight;
|
height = this.minHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
if (height > window.innerHeight) {
|
if (height > window.innerHeight) {
|
||||||
height = window.innerHeight;
|
height = window.innerHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
this.size = {width, height};
|
this.size = {width, height}
|
||||||
el.style.width = width + 'px';
|
el.style.width = width + 'px'
|
||||||
el.style.height = height + 'px';
|
el.style.height = height + 'px'
|
||||||
|
|
||||||
this.$emit('resize', {
|
this.$emit('resize', {
|
||||||
element: el,
|
element: el,
|
||||||
size: this.size
|
size: this.size
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
28
src/index.js
Normal file
28
src/index.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import Modal from './Modal.vue'
|
||||||
|
|
||||||
|
const ModalPlugin = {
|
||||||
|
install(Vue, options = {}) {
|
||||||
|
if (!this.hasOwnProperty("event")) {
|
||||||
|
this.event = new Vue()
|
||||||
|
}
|
||||||
|
|
||||||
|
const $modal = {
|
||||||
|
show(name, params) {
|
||||||
|
ModalPlugin.event.$emit('toggle', name, true, params)
|
||||||
|
},
|
||||||
|
hide(name, params) {
|
||||||
|
ModalPlugin.event.$emit('toggle', name, false, params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(Vue.prototype, '$modal', {
|
||||||
|
get: () => $modal
|
||||||
|
})
|
||||||
|
|
||||||
|
Vue.component('modal', Modal)
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ModalPlugin
|
||||||
@@ -1,17 +1,13 @@
|
|||||||
|
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
var webpack = require('webpack')
|
var webpack = require('webpack')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: './examples/src/main.js',
|
entry: './src/index.js',
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, './dist'),
|
path: path.resolve(__dirname, './dist'),
|
||||||
publicPath: '/dist/',
|
publicPath: '/dist/',
|
||||||
filename: 'build.js'
|
filename: 'index.js'
|
||||||
},
|
},
|
||||||
externals: [
|
|
||||||
|
|
||||||
],
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@@ -19,9 +15,13 @@ module.exports = {
|
|||||||
loader: 'vue-loader',
|
loader: 'vue-loader',
|
||||||
options: {
|
options: {
|
||||||
loaders: {
|
loaders: {
|
||||||
|
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
|
||||||
|
// the "scss" and "sass" values for the lang attribute to the right configs here.
|
||||||
|
// other preprocessors should work out of the box, no loader config like this necessary.
|
||||||
'scss': 'vue-style-loader!css-loader!sass-loader',
|
'scss': 'vue-style-loader!css-loader!sass-loader',
|
||||||
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
|
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
|
||||||
}
|
}
|
||||||
|
// other vue-loader options go here
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -40,12 +40,12 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'vue': 'vue/dist/vue.js',
|
'vue$': 'vue/dist/vue.esm.js'
|
||||||
'nice-vue-components$': path.resolve(__dirname, './components/index.js')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
historyApiFallback: true
|
historyApiFallback: true,
|
||||||
|
noInfo: true
|
||||||
},
|
},
|
||||||
performance: {
|
performance: {
|
||||||
hints: false
|
hints: false
|
||||||
@@ -54,20 +54,28 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
module.exports.entry = './src/index.js'
|
||||||
|
|
||||||
|
module.exports.output = {
|
||||||
|
path:'./dist',
|
||||||
|
filename:'index.js',
|
||||||
|
library:'VueJsToggleButton',
|
||||||
|
libraryTarget: 'umd'
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.devtool = '#source-map'
|
module.exports.devtool = '#source-map'
|
||||||
// http://vue-loader.vuejs.org/en/workflow/production.html
|
|
||||||
module.exports.plugins = (module.exports.plugins || []).concat([
|
module.exports.plugins = (module.exports.plugins || []).concat([
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': {
|
'process.env': {
|
||||||
NODE_ENV: '"production"'
|
NODE_ENV: '"production"'
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
new webpack.optimize.UglifyJsPlugin({
|
/*new webpack.optimize.UglifyJsPlugin({
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
compress: {
|
compress: {
|
||||||
warnings: false
|
warnings: false
|
||||||
}
|
}
|
||||||
}),
|
}),*/
|
||||||
new webpack.LoaderOptionsPlugin({
|
new webpack.LoaderOptionsPlugin({
|
||||||
minimize: true
|
minimize: true
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user