Skip to content

Commit 9cbd7ca

Browse files
committed
Set up babel
1 parent 45602ab commit 9cbd7ca

4 files changed

Lines changed: 39 additions & 28 deletions

File tree

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
["es2015", {"modules": false}]
4+
]
5+
}

bundle.js

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,8 @@
7070
/* 0 */
7171
/***/ (function(module, exports) {
7272

73-
const data = {
74-
icons: [
75-
'square',
76-
'circle',
77-
'rectangle-vertical',
78-
'rectangle-horizontal'
79-
]
73+
var data = {
74+
icons: ['square', 'circle', 'rectangle-vertical', 'rectangle-horizontal']
8075
};
8176

8277
Vue.component('icon', {
@@ -91,26 +86,25 @@ Vue.component('icon', {
9186
}
9287
},
9388
template: '#icon-template',
94-
mounted() {
95-
fetch(`./icons/${this.name}.svg`)
96-
.then(response => {
97-
if (response.ok) {
98-
return response.text();
99-
}
100-
throw new Error(`Cannot find ${this.name}.svg`);
101-
})
102-
.then(svgText => {
103-
const svgDocument = new DOMParser().parseFromString(svgText, 'image/svg+xml');
104-
const svgIcon = svgDocument.querySelector('svg').cloneNode(true);
105-
106-
svgIcon.setAttribute('width', this.size);
107-
svgIcon.setAttribute('height', this.size);
108-
109-
this.$el.appendChild(svgIcon);
110-
})
111-
.catch(error => {
112-
console.error(error);
113-
});
89+
mounted: function mounted() {
90+
var _this = this;
91+
92+
fetch('./icons/' + this.name + '.svg').then(function (response) {
93+
if (response.ok) {
94+
return response.text();
95+
}
96+
throw new Error('Cannot find ' + _this.name + '.svg');
97+
}).then(function (svgText) {
98+
var svgDocument = new DOMParser().parseFromString(svgText, 'image/svg+xml');
99+
var svgIcon = svgDocument.querySelector('svg').cloneNode(true);
100+
101+
svgIcon.setAttribute('width', _this.size);
102+
svgIcon.setAttribute('height', _this.size);
103+
104+
_this.$el.appendChild(svgIcon);
105+
}).catch(function (error) {
106+
console.error(error);
107+
});
114108
}
115109
});
116110

@@ -122,7 +116,7 @@ Vue.component('icon-container', {
122116
}
123117
},
124118
template: '#icon-container-template'
125-
})
119+
});
126120

127121
new Vue({
128122
el: '#app',

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "feather",
33
"version": "0.0.0",
44
"devDependencies": {
5+
"babel-core": "^6.22.1",
6+
"babel-loader": "^6.2.10",
7+
"babel-preset-es2015": "^6.22.0",
58
"webpack": "^2.2.0"
69
}
710
}

webpack.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,14 @@ module.exports = {
55
output: {
66
path: path.resolve(__dirname),
77
filename: 'bundle.js'
8+
},
9+
module: {
10+
rules: [
11+
{
12+
test: /\.js$/,
13+
loader: 'babel-loader',
14+
exclude: /node_modules/
15+
}
16+
]
817
}
918
}

0 commit comments

Comments
 (0)