Set up babel

This commit is contained in:
Cole Bemis 2017-01-28 14:46:21 -08:00
parent 45602abe9e
commit 9cbd7ca24d
4 changed files with 37 additions and 26 deletions

5
.babelrc Normal file
View File

@ -0,0 +1,5 @@
{
"presets": [
["es2015", {"modules": false}]
]
}

View File

@ -70,13 +70,8 @@
/* 0 */
/***/ (function(module, exports) {
const data = {
icons: [
'square',
'circle',
'rectangle-vertical',
'rectangle-horizontal'
]
var data = {
icons: ['square', 'circle', 'rectangle-vertical', 'rectangle-horizontal']
};
Vue.component('icon', {
@ -91,24 +86,23 @@ Vue.component('icon', {
}
},
template: '#icon-template',
mounted() {
fetch(`./icons/${this.name}.svg`)
.then(response => {
mounted: function mounted() {
var _this = this;
fetch('./icons/' + this.name + '.svg').then(function (response) {
if (response.ok) {
return response.text();
}
throw new Error(`Cannot find ${this.name}.svg`);
})
.then(svgText => {
const svgDocument = new DOMParser().parseFromString(svgText, 'image/svg+xml');
const svgIcon = svgDocument.querySelector('svg').cloneNode(true);
throw new Error('Cannot find ' + _this.name + '.svg');
}).then(function (svgText) {
var svgDocument = new DOMParser().parseFromString(svgText, 'image/svg+xml');
var svgIcon = svgDocument.querySelector('svg').cloneNode(true);
svgIcon.setAttribute('width', this.size);
svgIcon.setAttribute('height', this.size);
svgIcon.setAttribute('width', _this.size);
svgIcon.setAttribute('height', _this.size);
this.$el.appendChild(svgIcon);
})
.catch(error => {
_this.$el.appendChild(svgIcon);
}).catch(function (error) {
console.error(error);
});
}
@ -122,7 +116,7 @@ Vue.component('icon-container', {
}
},
template: '#icon-container-template'
})
});
new Vue({
el: '#app',

View File

@ -2,6 +2,9 @@
"name": "feather",
"version": "0.0.0",
"devDependencies": {
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.22.0",
"webpack": "^2.2.0"
}
}

View File

@ -5,5 +5,14 @@ module.exports = {
output: {
path: path.resolve(__dirname),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
}
}