Skip to content

Commit

Permalink
Update to fix a bug when building with Laravel Elixir with the --prod…
Browse files Browse the repository at this point in the history
…uction flag

Signed-off-by: Javis Perez <[email protected]>
  • Loading branch information
javisperez committed Sep 16, 2016
1 parent a6d4ae2 commit 83b2678
Show file tree
Hide file tree
Showing 10 changed files with 534 additions and 145 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
.DS_Store
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
72 changes: 72 additions & 0 deletions build/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
var fs = require('fs');
var rollup = require('rollup');
var uglify = require('uglify-js');
var babel = require('rollup-plugin-babel');
var package = require('../package.json');
var banner =
"/**\n" +
" * VueTranslate plugin v" + package.version + "\n" +
" *\n"+
" * Handle basic translations in VueJS\n"+
" *\n"+
" * This is a plugin to handle basic translations for a component in VueJS."+
" * @author Javis Perez <[email protected]>\n"+
" * https://github.com/javisperez/vuetranslate\n"+
" * Released under the MIT License.\n" +
" */\n";

rollup.rollup({
entry: 'src/vue-translate.js',
plugins: [
babel({
presets: ['es2015-loose-rollup']
})
]
})
.then(function (bundle) {
return write('dist/vue-translate.js', bundle.generate({
format: 'umd',
banner: banner,
moduleName: 'VueTranslate'
}).code, bundle);
})
.then(function (bundle) {
return write('dist/vue-translate.min.js',
banner + '\n' + uglify.minify('dist/vue-translate.js').code,
bundle);
})
.then(function (bundle) {
return write('dist/vue-translate.es2015.js', bundle.generate({
banner: banner,
footer: 'export { Url, Http, Resource };'
}).code, bundle);
})
.then(function (bundle) {
return write('dist/vue-translate.common.js', bundle.generate({
format: 'cjs',
banner: banner
}).code, bundle);
})
.catch(logError);

function write(dest, code, bundle) {
return new Promise(function (resolve, reject) {
fs.writeFile(dest, code, function (err) {
if (err) return reject(err);
console.log(blue(dest) + ' ' + getSize(code));
resolve(bundle);
});
});
}

function getSize(code) {
return (code.length / 1024).toFixed(2) + 'kb';
}

function logError(e) {
console.log(e);
}

function blue(str) {
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m';
}
102 changes: 102 additions & 0 deletions dist/vue-translate.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
* VueTranslate plugin v1.1.0
*
* Handle basic translations in VueJS
*
* This is a plugin to handle basic translations for a component in VueJS. * @author Javis Perez <[email protected]>
* https://github.com/javisperez/vuetranslate
* Released under the MIT License.
*/

'use strict';

// We need a vue instance to handle reactivity
var vm = null;

// The plugin
var VueTranslate = {

// Install the method

install: function (Vue) {
var _Vue$mixin;

var version = Vue.version[0];

if (!vm) {
vm = new Vue({
data: function () {
return {
current: '',
locales: {}
};
},


computed: {
locale: function () {
if (!this.locales[this.current]) return null;

return this.locales[this.current];
}
},

methods: {
setLang: function (val) {
this.current = val;
},
setLocales: function (locales) {
if (!locales) return;

var newLocale = Object.create(this.locales);

for (var key in locales) {
if (!newLocale[key]) newLocale[key] = {};

Vue.util.extend(newLocale[key], locales[key]);
}

this.locales = Object.create(newLocale);
},
text: function (t) {
if (!this.locale || !this.locale[t]) {
return t;
}

return this.locale[t];
}
}
});

Vue.prototype.$translate = vm;
}

// Mixin to read locales and add the translation method and directive
Vue.mixin((_Vue$mixin = {}, _Vue$mixin[version === '1' ? 'init' : 'beforeCreate'] = function () {
this.$translate.setLocales(this.$options.locales);
}, _Vue$mixin.methods = {
t: function (t) {
return this.$translate.text(t);
}
}, _Vue$mixin.directives = {
translate: function (el) {
if (!el.$translateKey) el.$translateKey = el.innerText;

var text = this.$translate.text(el.$translateKey);

el.innerText = text;
}.bind(vm)
}, _Vue$mixin));
}
};

if (typeof exports === 'object') {
module.exports = VueTranslate; // CommonJS
} else if (typeof define === 'function' && define.amd) {
define([], function () {
return VueTranslate;
}); // AMD
} else if (window.Vue) {
window.VueTranslate = VueTranslate; // Browser (not required options)
Vue.use(VueTranslate);
}
101 changes: 101 additions & 0 deletions dist/vue-translate.es2015.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* VueTranslate plugin v1.1.0
*
* Handle basic translations in VueJS
*
* This is a plugin to handle basic translations for a component in VueJS. * @author Javis Perez <[email protected]>
* https://github.com/javisperez/vuetranslate
* Released under the MIT License.
*/

// We need a vue instance to handle reactivity
var vm = null;

// The plugin
var VueTranslate = {

// Install the method

install: function (Vue) {
var _Vue$mixin;

var version = Vue.version[0];

if (!vm) {
vm = new Vue({
data: function () {
return {
current: '',
locales: {}
};
},


computed: {
locale: function () {
if (!this.locales[this.current]) return null;

return this.locales[this.current];
}
},

methods: {
setLang: function (val) {
this.current = val;
},
setLocales: function (locales) {
if (!locales) return;

var newLocale = Object.create(this.locales);

for (var key in locales) {
if (!newLocale[key]) newLocale[key] = {};

Vue.util.extend(newLocale[key], locales[key]);
}

this.locales = Object.create(newLocale);
},
text: function (t) {
if (!this.locale || !this.locale[t]) {
return t;
}

return this.locale[t];
}
}
});

Vue.prototype.$translate = vm;
}

// Mixin to read locales and add the translation method and directive
Vue.mixin((_Vue$mixin = {}, _Vue$mixin[version === '1' ? 'init' : 'beforeCreate'] = function () {
this.$translate.setLocales(this.$options.locales);
}, _Vue$mixin.methods = {
t: function (t) {
return this.$translate.text(t);
}
}, _Vue$mixin.directives = {
translate: function (el) {
if (!el.$translateKey) el.$translateKey = el.innerText;

var text = this.$translate.text(el.$translateKey);

el.innerText = text;
}.bind(vm)
}, _Vue$mixin));
}
};

if (typeof exports === 'object') {
module.exports = VueTranslate; // CommonJS
} else if (typeof define === 'function' && define.amd) {
define([], function () {
return VueTranslate;
}); // AMD
} else if (window.Vue) {
window.VueTranslate = VueTranslate; // Browser (not required options)
Vue.use(VueTranslate);
}
export { Url, Http, Resource };
108 changes: 108 additions & 0 deletions dist/vue-translate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* VueTranslate plugin v1.1.0
*
* Handle basic translations in VueJS
*
* This is a plugin to handle basic translations for a component in VueJS. * @author Javis Perez <[email protected]>
* https://github.com/javisperez/vuetranslate
* Released under the MIT License.
*/

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';

// We need a vue instance to handle reactivity
var vm = null;

// The plugin
var VueTranslate = {

// Install the method

install: function (Vue) {
var _Vue$mixin;

var version = Vue.version[0];

if (!vm) {
vm = new Vue({
data: function () {
return {
current: '',
locales: {}
};
},


computed: {
locale: function () {
if (!this.locales[this.current]) return null;

return this.locales[this.current];
}
},

methods: {
setLang: function (val) {
this.current = val;
},
setLocales: function (locales) {
if (!locales) return;

var newLocale = Object.create(this.locales);

for (var key in locales) {
if (!newLocale[key]) newLocale[key] = {};

Vue.util.extend(newLocale[key], locales[key]);
}

this.locales = Object.create(newLocale);
},
text: function (t) {
if (!this.locale || !this.locale[t]) {
return t;
}

return this.locale[t];
}
}
});

Vue.prototype.$translate = vm;
}

// Mixin to read locales and add the translation method and directive
Vue.mixin((_Vue$mixin = {}, _Vue$mixin[version === '1' ? 'init' : 'beforeCreate'] = function () {
this.$translate.setLocales(this.$options.locales);
}, _Vue$mixin.methods = {
t: function (t) {
return this.$translate.text(t);
}
}, _Vue$mixin.directives = {
translate: function (el) {
if (!el.$translateKey) el.$translateKey = el.innerText;

var text = this.$translate.text(el.$translateKey);

el.innerText = text;
}.bind(vm)
}, _Vue$mixin));
}
};

if (typeof exports === 'object') {
module.exports = VueTranslate; // CommonJS
} else if (typeof define === 'function' && define.amd) {
define([], function () {
return VueTranslate;
}); // AMD
} else if (window.Vue) {
window.VueTranslate = VueTranslate; // Browser (not required options)
Vue.use(VueTranslate);
}

})));
Loading

0 comments on commit 83b2678

Please sign in to comment.