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 */ /* 0 */
/***/ (function(module, exports) { /***/ (function(module, exports) {
const data = { var data = {
icons: [ icons: ['square', 'circle', 'rectangle-vertical', 'rectangle-horizontal']
'square',
'circle',
'rectangle-vertical',
'rectangle-horizontal'
]
}; };
Vue.component('icon', { Vue.component('icon', {
@ -91,26 +86,25 @@ Vue.component('icon', {
} }
}, },
template: '#icon-template', template: '#icon-template',
mounted() { mounted: function mounted() {
fetch(`./icons/${this.name}.svg`) var _this = this;
.then(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);
svgIcon.setAttribute('width', this.size); fetch('./icons/' + this.name + '.svg').then(function (response) {
svgIcon.setAttribute('height', this.size); if (response.ok) {
return response.text();
}
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);
this.$el.appendChild(svgIcon); svgIcon.setAttribute('width', _this.size);
}) svgIcon.setAttribute('height', _this.size);
.catch(error => {
console.error(error); _this.$el.appendChild(svgIcon);
}); }).catch(function (error) {
console.error(error);
});
} }
}); });
@ -122,7 +116,7 @@ Vue.component('icon-container', {
} }
}, },
template: '#icon-container-template' template: '#icon-container-template'
}) });
new Vue({ new Vue({
el: '#app', el: '#app',

View File

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

View File

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