Skip to content

Commit

Permalink
fix(): Add webpack support to build src with babel
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridermansb committed Oct 6, 2016
1 parent 5a291c1 commit fa8d1d2
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,4 @@ fabric.properties
# modules.xml
# .idea/misc.xml
# *.ipr
dist
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.*
*.log
*.swp
*.yml
coverage
docs/_book
config
dist/*.map
lib
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ before_install:
before_script:
- npm prune
after_success:
- npm run build
- npm run semantic-release
branches:
except:
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"description": "Vue.js plugin that allow search address and places using Google Maps API",
"main": "dist/index.js",
"scripts": {
"build": "webpack --progress --colors",
"commit": "./node_modules/.bin/git-cz",
"test": "true",
"test": "standard --verbose | snazzy",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"keywords": [
Expand All @@ -26,8 +27,15 @@
"load-google-maps-api": "0.0.2"
},
"devDependencies": {
"babel-core": "6.17.0",
"babel-loader": "6.2.5",
"babel-preset-es2015": "6.16.0",
"cz-conventional-changelog": "1.2.0",
"semantic-release": "^4.3.5"
"semantic-release": "^4.3.5",
"snazzy": "5.0.0",
"standard": "8.3.0",
"standard-loader": "5.0.0",
"webpack": "1.13.2"
},
"config": {
"commitizen": {
Expand Down
27 changes: 13 additions & 14 deletions index.js → src/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
var loadGoogleMapsAPI = require('load-google-maps-api')

function plugin (Vue, options) {
import loadGoogleMapsAPI from 'load-google-maps-api'

function plugin (Vue, {
libraries = [ 'places' ],
key,
client,
version = '3.26'
} = {}) {
if (plugin.installed) {
return
}

var libraries = options && options.libraries ? options.libraries : [ 'places' ]
var key = options && options.key ? options.key : ''
var client = options && options.client ? options.client : ''
var version = options && options.version ? options.version : '3.26'

Vue.directive('gmaps-searchbox', {
inserted: function (el, binding) {
let propertyToSet = binding.arg ? binding.arg : 'place'
const propertyToSet = binding.arg ? binding.arg : 'place'
ensureGoogleMaps(() => {
var searchBox = new Vue.gmaps.places.SearchBox(el)
searchBox.addListener('places_changed', function () {
var places = searchBox.getPlaces()
if (places.length == 0) {
if (places.length === 0) {
return
}

let place = {}
let originalPlace = places[0]
let originalPlace = places[ 0 ]
var keys = Object.keys(binding.modifiers)
if (keys.length > 0) {
keys.forEach(function (key) {
place[key] = originalPlace[key]
place[ key ] = originalPlace[ key ]
})
} else {
place = originalPlace
Expand All @@ -49,7 +48,7 @@ function plugin (Vue, options) {
Vue.gmaps = google
Object.defineProperties(Vue.prototype, {
$gmaps: {
get() {
get () {
console.log('get. ', this)
return Vue.gmaps
}
Expand All @@ -61,7 +60,7 @@ function plugin (Vue, options) {
}
}

plugin.version = '0.0.3'
plugin.version = '0.0.4'

export default plugin

Expand Down
34 changes: 34 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const path = require('path');
const webpack = require('webpack')

module.exports = {
entry: "./src/index.js",
output: {
path: path.join(__dirname, 'dist'),
filename: "index.js"
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
loader: 'standard',
exclude: /(node_modules)/
}
],
loaders: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, "src"),
],
exclude: [
path.resolve(__dirname, "node_modules"),
],
loader: 'babel',
query: {
presets: [ 'es2015' ]
}
}
]
}
};

0 comments on commit fa8d1d2

Please sign in to comment.