Skip to content

Commit 87f9654

Browse files
committed
Prepared and published to npm
1 parent 6c25aa1 commit 87f9654

File tree

7 files changed

+142
-117
lines changed

7 files changed

+142
-117
lines changed

build/webpack.prod.conf.js

Lines changed: 49 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -14,115 +14,55 @@ const env = process.env.NODE_ENV === 'testing'
1414
? require('../config/test.env')
1515
: config.build.env
1616

17-
const webpackConfig = merge(baseWebpackConfig, {
18-
module: {
19-
rules: utils.styleLoaders({
20-
sourceMap: config.build.productionSourceMap,
21-
extract: true
22-
})
23-
},
24-
devtool: config.build.productionSourceMap ? '#source-map' : false,
25-
output: {
26-
path: config.build.assetsRoot,
27-
filename: utils.assetsPath('js/[name].[chunkhash].js'),
28-
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
29-
},
30-
plugins: [
31-
// http://vuejs.github.io/vue-loader/en/workflow/production.html
32-
new webpack.DefinePlugin({
33-
'process.env': env
17+
const webpackConfig = [
18+
merge(baseWebpackConfig, {
19+
entry: path.resolve(__dirname + '/../src/App.vue'),
20+
output: {
21+
filename: 'vue-dots.js',
22+
libraryTarget: 'umd',
23+
library: 'vue-dots',
24+
umdNamedDefine: true
25+
},
26+
plugins: [
27+
new webpack.optimize.UglifyJsPlugin( {
28+
minimize : true,
29+
sourceMap : false,
30+
mangle: true,
31+
compress: {
32+
warnings: false
33+
}
34+
}),
35+
// extract css into its own file
36+
new ExtractTextPlugin({
37+
filename: utils.assetsPath('../vue-dots.css')
38+
})
39+
]
40+
}),
41+
merge(baseWebpackConfig, {
42+
entry: path.resolve(__dirname + '/../src/plugin.js'),
43+
output: {
44+
filename: 'vue-dots.min.js',
45+
libraryTarget: 'window',
46+
library: 'VueDots'
47+
},
48+
externals: {
49+
vue: 'vue'
50+
},
51+
plugins: [
52+
new webpack.optimize.UglifyJsPlugin( {
53+
minimize : true,
54+
sourceMap : false,
55+
mangle: true,
56+
compress: {
57+
warnings: false
58+
}
3459
}),
35-
// UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/babel/minify
36-
new webpack.optimize.UglifyJsPlugin({
37-
compress: {
38-
warnings: false
39-
},
40-
sourceMap: true
41-
}),
42-
// extract css into its own file
43-
new ExtractTextPlugin({
44-
filename: utils.assetsPath('css/[name].[contenthash].css')
45-
}),
46-
// Compress extracted CSS. We are using this plugin so that possible
47-
// duplicated CSS from different components can be deduped.
48-
new OptimizeCSSPlugin({
49-
cssProcessorOptions: {
50-
safe: true
51-
}
52-
}),
53-
// generate dist index.html with correct asset hash for caching.
54-
// you can customize output by editing /index.html
55-
// see https://github.com/ampedandwired/html-webpack-plugin
56-
new HtmlWebpackPlugin({
57-
filename: process.env.NODE_ENV === 'testing'
58-
? 'index.html'
59-
: config.build.index,
60-
template: 'index.html',
61-
inject: true,
62-
minify: {
63-
removeComments: true,
64-
collapseWhitespace: true,
65-
removeAttributeQuotes: true
66-
// more options:
67-
// https://github.com/kangax/html-minifier#options-quick-reference
68-
},
69-
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
70-
chunksSortMode: 'dependency'
71-
}),
72-
// keep module.id stable when vender modules does not change
73-
new webpack.HashedModuleIdsPlugin(),
74-
// split vendor js into its own file
75-
new webpack.optimize.CommonsChunkPlugin({
76-
name: 'vendor',
77-
minChunks: function (module) {
78-
// any required modules inside node_modules are extracted to vendor
79-
return (
80-
module.resource &&
81-
/\.js$/.test(module.resource) &&
82-
module.resource.indexOf(
83-
path.join(__dirname, '../node_modules')
84-
) === 0
85-
)
86-
}
87-
}),
88-
// extract webpack runtime and module manifest to its own file in order to
89-
// prevent vendor hash from being updated whenever app bundle is updated
90-
new webpack.optimize.CommonsChunkPlugin({
91-
name: 'manifest',
92-
chunks: ['vendor']
93-
}),
94-
// copy custom static assets
95-
new CopyWebpackPlugin([
96-
{
97-
from: path.resolve(__dirname, '../static'),
98-
to: config.build.assetsSubDirectory,
99-
ignore: ['.*']
100-
}
101-
])
102-
]
103-
})
104-
105-
if (config.build.productionGzip) {
106-
const CompressionWebpackPlugin = require('compression-webpack-plugin')
107-
108-
webpackConfig.plugins.push(
109-
new CompressionWebpackPlugin({
110-
asset: '[path].gz[query]',
111-
algorithm: 'gzip',
112-
test: new RegExp(
113-
'\\.(' +
114-
config.build.productionGzipExtensions.join('|') +
115-
')$'
116-
),
117-
threshold: 10240,
118-
minRatio: 0.8
119-
})
120-
)
121-
}
122-
123-
if (config.build.bundleAnalyzerReport) {
124-
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
125-
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
126-
}
60+
// extract css into its own file
61+
new ExtractTextPlugin({
62+
filename: utils.assetsPath('../vue-dots.css')
63+
})
64+
]
65+
})
66+
]
12767

12868
module.exports = webpackConfig

package.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "vue-dots",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Show dots and connections among them",
5-
"author": "Yuselis Castano <ycastano87@gmail.com>",
6-
"private": true,
5+
"author": "Robert Carcasses Quevedo <carcasses@gmail.com>",
6+
"license": "MIT",
77
"scripts": {
88
"dev": "node build/dev-server.js",
99
"start": "npm run dev",
@@ -12,6 +12,19 @@
1212
"test": "npm run unit",
1313
"lint": "eslint --ext .js,.vue src test/unit/specs"
1414
},
15+
"homepage": "https://github.com/rcarcasses/vue-dots",
16+
"bugs": "https://github.com/rcarcasses/vue-dots/issues",
17+
"repository": {
18+
"url": "https://github.com/rcarcasses/vue-dots",
19+
"type": "git"
20+
},
21+
"contributors": [
22+
"Yuselis Castano Guerrero <[email protected]>"
23+
],
24+
"files": [
25+
"dist/**/*"
26+
],
27+
"main": "dist/vue-dots.js",
1528
"dependencies": {
1629
"vue": "^2.4.2"
1730
},

src/App.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
<template>
22
<div id="app">
3-
<svg-dots/>
3+
<svg-dots :store="store"/>
44
</div>
55
</template>
66

77
<script>
88
import SVGDots from './components/SVGDots'
9+
import {store} from './components/store'
910
1011
export default {
1112
name: 'app',
13+
data () {
14+
return {
15+
store
16+
}
17+
},
1218
components: {
1319
'svg-dots': SVGDots
1420
}

src/components/SVGDots.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ import ZoomOut from './icons/ZoomOut'
3838
import Delete from './icons/Delete'
3939
import Move from './icons/Move'
4040
import BuildPath from './icons/BuildPath'
41-
import {BUILD, MOVE, DELETE, store} from './store'
41+
import {BUILD, MOVE, DELETE} from './store'
4242
4343
export default {
44+
props: ['store'],
4445
components: {
4546
ZoomIn,
4647
ZoomOut,
@@ -65,8 +66,8 @@ export default {
6566
beingDragId: -1, // who is being dragged
6667
isDragging: false, // says if we are currently dragging something
6768
isEditing: true,
68-
state: store.state,
69-
actions: store.actions
69+
state: this.store.state,
70+
actions: this.store.actions
7071
}
7172
},
7273
methods: {

src/components/store.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const state = {
1717
}
1818

1919
function getNewNodeId () {
20-
return state.lastId++
20+
const newId = state.lastId += 1
21+
return newId
2122
}
2223

2324
function createNode (x, y) {

src/plugin.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import VueDots from './App.vue'
2+
3+
module.exports = {
4+
install: function (Vue, options) {
5+
Vue.component('vue-dots', VueDots)
6+
}
7+
}

webpack.lib.conf.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const webpack = require('webpack');
2+
const merge = require('webpack-merge');
3+
const path = require('path');
4+
5+
var config = {
6+
output: {
7+
path: path.resolve(__dirname + '/lib/'),
8+
},
9+
module: {
10+
loaders: [
11+
{
12+
test: /\.js$/,
13+
loader: 'babel',
14+
include: __dirname,
15+
exclude: /node_modules/
16+
},
17+
{
18+
test: /\.vue$/,
19+
loader: 'vue'
20+
},
21+
{
22+
test: /\.css$/,
23+
loader: 'style!less!css'
24+
}
25+
]
26+
},
27+
plugins: [
28+
new webpack.optimize.UglifyJsPlugin( {
29+
minimize : true,
30+
sourceMap : false,
31+
mangle: true,
32+
compress: {
33+
warnings: false
34+
}
35+
})
36+
]
37+
};
38+
39+
module.exports = [
40+
merge(config, {
41+
entry: path.resolve(__dirname + '/src/plugin.js'),
42+
output: {
43+
filename: 'vue-dots.min.js',
44+
libraryTarget: 'window',
45+
library: 'VueDots',
46+
}
47+
}),
48+
merge(config, {
49+
entry: path.resolve(__dirname + '/src/App.vue'),
50+
output: {
51+
filename: 'vue-dots.js',
52+
libraryTarget: 'umd',
53+
library: 'vue-dots',
54+
umdNamedDefine: true
55+
}
56+
})
57+
];

0 commit comments

Comments
 (0)