Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"dependencies": {
"babel-eslint": "^7.2.3",
"babel-preset-es2015": "^6.24.1",
"butternut": "^0.4.6",
"camel-case": "^3.0.0",
"clean-css": "^4.1.7",
"dedupe": "^2.1.0",
Expand Down
10 changes: 9 additions & 1 deletion src/renderer/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
const Utils = require('../utils');
const Vue = require('vue');

const butternut = require('butternut');
const buttterNutOptions = {
sourceMap: false
};

function createApp(script) {
return new Vue(script);
}
Expand All @@ -28,7 +33,10 @@ function renderedScript(script: Object, router): string {
if (process.env.VUE_DEV) {
debugToolsString = 'Vue.config.devtools = true;';
}
return `<script>\n(function () {'use strict';${routerString}var createApp = function () {return new Vue(${scriptString})};if (typeof module !== 'undefined' && module.exports) {module.exports = createApp} else {this.app = createApp()}}).call(this);${debugToolsString}app.$mount('#app');\n</script>`;
const javaScriptString = `(function () {'use strict';${routerString}var createApp = function () {return new Vue(${scriptString})};if (typeof module !== 'undefined' && module.exports) {module.exports = createApp} else {this.app = createApp()}}).call(this);${debugToolsString}app.$mount('#app');`;
const finalString = butternut.squash(javaScriptString, buttterNutOptions).code;

return `<script>${finalString}</script>`;
}

type htmlUtilType = {
Expand Down
8 changes: 1 addition & 7 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ const vueOptions = {
}

const exampleHead = `<head>\n<title>Page Title</title>\n</head>`;
const exampleScript = `<script>
(function () {'use strict';var createApp = function () {return new Vue({mixins: [{methods: {hello: function hello() {
console.log('Hello');
},},},],data: function(){return {"title":"Express Vue","message":"Hello world","uuid":"farts"}},methods: {test: function test() {
console.error('test');
},},components: {uuid: {props: ["uuid"],data: function(){return {}},template: "<div><h2>Uuid: {{uuid ? uuid : 'no uuid'}}</h2></div>",},uuid2: {props: ["uuid2"],data: function(){return {}},template: "<div><h3>Uuid2: {{uuid2 ? uuid2 : 'no uuid'}}</h3></div>",},},template: "<div><h1>{{title}}</h1><p>Welcome to the {{title}} demo. Click a link:</p><input v-model=\\"message\\" placeholder=\\"edit me\\"><p>{{message}}</p><uuid :uuid=\\"uuid\\"></uuid><uuid2 :uuid2=\\"uuid2\\"></uuid2><button type=\\"button\\" name=\\"button\\" v-on:click=\\"this.hello\\">Test mixin</button> <button type=\\"button\\" name=\\"button\\" v-on:click=\\"this.test\\">Test method</button></div>",})};if (typeof module !== 'undefined' && module.exports) {module.exports = createApp} else {this.app = createApp()}}).call(this);app.$mount('#app');
</script>`
const exampleScript = `<script>(function(){"use strict";var u=function(){return new Vue({mixins:[{methods:{hello:function(){console.log('Hello')}}}],data:function(){return{"title":"Express Vue","message":"Hello world","uuid":"farts"}},methods:{test:function(){console.error('test')}},components:{uuid:{props:["uuid"],data:function(){return{}},template:"<div><h2>Uuid: {{uuid ? uuid : 'no uuid'}}</h2></div>"},uuid2:{props:["uuid2"],data:function(){return{}},template:"<div><h3>Uuid2: {{uuid2 ? uuid2 : 'no uuid'}}</h3></div>"}},template:"<div><h1>{{title}}</h1><p>Welcome to the {{title}} demo. Click a link:</p><input v-model=\\"message\\" placeholder=\\"edit me\\"><p>{{message}}</p><uuid :uuid=\\"uuid\\"></uuid><uuid2 :uuid2=\\"uuid2\\"></uuid2><button type=\\"button\\" name=\\"button\\" v-on:click=\\"this.hello\\">Test mixin</button> <button type=\\"button\\" name=\\"button\\" v-on:click=\\"this.test\\">Test method</button></div>"})};typeof module!=='undefined'&&module.exports?(module.exports=u):(this.app=u())}).call(this),app.$mount('#app')</script>`

test('renders App object', t => {
const renderer = new ExpressVueRenderer(options);
Expand Down