generator done

This commit is contained in:
Alexandre Chopin 2016-11-10 13:24:20 +01:00
parent e0641e1e51
commit 06694e32ce
12 changed files with 887 additions and 34 deletions

View File

@ -0,0 +1 @@
webpackJsonp([0],{24:function(t,n,e){var o,r;e(27);var i=e(29);r=o=o||{},"object"!=typeof o.default&&"function"!=typeof o.default||(r=o=o.default),"function"==typeof r&&(r=r.options),r.render=i.render,r.staticRenderFns=i.staticRenderFns,r._scopeId="data-v-d30325b8",t.exports=o},27:function(t,n){},29:function(module,exports){module.exports={render:function(){with(this)return _h("div",{staticClass:"container"},[_m(0)," ",_m(1)," ",_h("p",[_h("router-link",{attrs:{to:"/"}},["Home"])])])},staticRenderFns:[function(){with(this)return _h("img",{attrs:{src:"/static/nuxt.png"}})},function(){with(this)return _h("h2",["About"])}]}}});

View File

@ -0,0 +1 @@
webpackJsonp([1],{25:function(t,n,e){var o,r;e(26);var i=e(28);r=o=o||{},"object"!=typeof o.default&&"function"!=typeof o.default||(r=o=o.default),"function"==typeof r&&(r=r.options),r.render=i.render,r.staticRenderFns=i.staticRenderFns,r._scopeId="data-v-9393702e",t.exports=o},26:function(t,n){},28:function(module,exports){module.exports={render:function(){with(this)return _h("div",{staticClass:"container"},[_m(0)," ",_m(1)," ",_h("p",[_h("router-link",{attrs:{to:"/about"}},["About"])])])},staticRenderFns:[function(){with(this)return _h("img",{attrs:{src:"/static/nuxt.png"}})},function(){with(this)return _h("h2",["Hello World."])}]}}});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,796 @@
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // identity function for calling harmory imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/ // define getter function for harmory exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ };
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 21);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports) {
module.exports = require("vue");
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.router = exports.app = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
var _vue = __webpack_require__(0);
var _vue2 = _interopRequireDefault(_vue);
var _router = __webpack_require__(8);
var _router2 = _interopRequireDefault(_router);
var _App = __webpack_require__(9);
var _App2 = _interopRequireDefault(_App);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// create the app instance.
// here we inject the router and store to all child components,
// making them available everywhere as `this.$router` and `this.$store`.
var app = _extends({
router: _router2.default
}, _App2.default);
exports.app = app;
exports.router = _router2.default;
/***/ },
/* 2 */
/***/ function(module, exports) {
"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getMatchedComponents = getMatchedComponents;
exports.flatMapComponents = flatMapComponents;
exports.getContext = getContext;
exports.getLocation = getLocation;
function getMatchedComponents(route) {
return [].concat.apply([], route.matched.map(function (m) {
return Object.keys(m.components).map(function (key) {
return m.components[key];
});
}));
}
function flatMapComponents(route, fn) {
return Array.prototype.concat.apply([], route.matched.map(function (m, index) {
return Object.keys(m.components).map(function (key) {
return fn(m.components[key], m.instances[key], m, key, index);
});
}));
}
function getContext(context) {
var ctx = {
isServer: !!context.isServer,
isClient: !!context.isClient,
route: context.to ? context.to : context.route
};
ctx.params = ctx.route.params || {};
ctx.query = ctx.route.query || {};
if (context.req) ctx.req = context.req;
if (context.res) ctx.res = context.res;
return ctx;
}
// Imported from vue-router
function getLocation(base) {
var path = window.location.pathname;
if (base && path.indexOf(base) === 0) {
path = path.slice(base.length);
}
return (path || '/') + window.location.search + window.location.hash;
}
/***/ },
/* 3 */
/***/ function(module, exports) {
module.exports = require("debug");
/***/ },
/* 4 */
/***/ function(module, exports) {
module.exports = require("lodash");
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _error = __webpack_require__(13);
var _error2 = _interopRequireDefault(_error);
var _Loading = __webpack_require__(10);
var _Loading2 = _interopRequireDefault(_Loading);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//
//
//
//
//
//
//
//
exports.default = {
data: function data() {
return {
err: null
};
},
mounted: function mounted() {
this.$loading = this.$refs.loading;
},
methods: {
error: function error(err) {
err = err || null;
this.err = err || null;
if (this.err && this.$loading && this.$loading.fail) {
this.$loading.fail();
}
return this.err;
}
},
components: {
NuxtError: _error2.default,
NuxtLoading: _Loading2.default
}
};
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
//
//
//
//
//
//
//
//
//
var Vue = __webpack_require__(0);
exports.default = {
data: function data() {
return {
percent: 0,
show: false,
canSuccess: true,
duration: 5000,
height: '2px',
color: 'black',
failedColor: 'red'
};
},
methods: {
start: function start() {
var _this = this;
this.show = true;
this.canSuccess = true;
if (this._timer) {
clearInterval(this._timer);
this.percent = 0;
}
this._cut = 10000 / Math.floor(this.duration);
this._timer = setInterval(function () {
_this.increase(_this._cut * Math.random());
if (_this.percent > 95) {
_this.finish();
}
}, 100);
return this;
},
set: function set(num) {
this.show = true;
this.canSuccess = true;
this.percent = Math.floor(num);
return this;
},
get: function get() {
return Math.floor(this.percent);
},
increase: function increase(num) {
this.percent = this.percent + Math.floor(num);
return this;
},
decrease: function decrease() {
this.percent = this.percent - Math.floor(num);
return this;
},
finish: function finish() {
this.percent = 100;
this.hide();
return this;
},
pause: function pause() {
clearInterval(this._timer);
return this;
},
hide: function hide() {
var _this2 = this;
clearInterval(this._timer);
this._timer = null;
setTimeout(function () {
_this2.show = false;
Vue.nextTick(function () {
setTimeout(function () {
_this2.percent = 0;
}, 200);
});
}, 500);
return this;
},
fail: function fail() {
this.canSuccess = false;
this.percent = 100;
this.hide();
return this;
}
}
};
/***/ },
/* 7 */
/***/ function(module, exports) {
"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
//
//
//
//
//
//
//
//
//
//
//
//
exports.default = {
props: ['error']
};
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _vue = __webpack_require__(0);
var _vue2 = _interopRequireDefault(_vue);
var _vueRouter = __webpack_require__(20);
var _vueRouter2 = _interopRequireDefault(_vueRouter);
var _vueMeta = __webpack_require__(19);
var _vueMeta2 = _interopRequireDefault(_vueMeta);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_vue2.default.use(_vueRouter2.default);
_vue2.default.use(_vueMeta2.default);
var _d30325b8 = false ? function () {
return System.import('/Users/Alexandre/Code/Github/nuxt.js/examples/hello-world/pages/about.vue');
} : __webpack_require__(11);
var _9393702e = false ? function () {
return System.import('/Users/Alexandre/Code/Github/nuxt.js/examples/hello-world/pages/index.vue');
} : __webpack_require__(12);
var scrollBehavior = function scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
// savedPosition is only available for popstate navigations.
return savedPosition;
} else {
// Scroll to the top by default
var position = { x: 0, y: 0 };
// if link has anchor, scroll to anchor by returning the selector
if (to.hash) {
position = { selector: to.hash };
}
return position;
}
};
exports.default = new _vueRouter2.default({
mode: 'history',
scrollBehavior: scrollBehavior,
routes: [{
path: '/about',
component: _d30325b8
}, {
path: '/',
component: _9393702e
}]
});
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
var __vue_exports__, __vue_options__
var __vue_styles__ = {}
/* script */
__vue_exports__ = __webpack_require__(5)
/* template */
var __vue_template__ = __webpack_require__(17)
__vue_options__ = __vue_exports__ = __vue_exports__ || {}
if (
typeof __vue_exports__.default === "object" ||
typeof __vue_exports__.default === "function"
) {
if (Object.keys(__vue_exports__).some(function (key) { return key !== "default" && key !== "__esModule" })) {console.error("named exports are not supported in *.vue files.")}
__vue_options__ = __vue_exports__ = __vue_exports__.default
}
if (typeof __vue_options__ === "function") {
__vue_options__ = __vue_options__.options
}
__vue_options__.__file = "/Users/Alexandre/Code/Github/nuxt.js/examples/hello-world/.nuxt/App.vue"
__vue_options__.render = __vue_template__.render
__vue_options__.staticRenderFns = __vue_template__.staticRenderFns
if (__vue_options__.functional) {console.error("[vue-loader] App.vue: functional components are not supported and should be defined in plain js files using render functions.")}
module.exports = __vue_exports__
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
var __vue_exports__, __vue_options__
var __vue_styles__ = {}
/* styles */
/* script */
__vue_exports__ = __webpack_require__(6)
/* template */
var __vue_template__ = __webpack_require__(14)
__vue_options__ = __vue_exports__ = __vue_exports__ || {}
if (
typeof __vue_exports__.default === "object" ||
typeof __vue_exports__.default === "function"
) {
if (Object.keys(__vue_exports__).some(function (key) { return key !== "default" && key !== "__esModule" })) {console.error("named exports are not supported in *.vue files.")}
__vue_options__ = __vue_exports__ = __vue_exports__.default
}
if (typeof __vue_options__ === "function") {
__vue_options__ = __vue_options__.options
}
__vue_options__.__file = "/Users/Alexandre/Code/Github/nuxt.js/examples/hello-world/.nuxt/components/Loading.vue"
__vue_options__.render = __vue_template__.render
__vue_options__.staticRenderFns = __vue_template__.staticRenderFns
__vue_options__._scopeId = "data-v-3223f20f"
if (__vue_options__.functional) {console.error("[vue-loader] Loading.vue: functional components are not supported and should be defined in plain js files using render functions.")}
module.exports = __vue_exports__
/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
var __vue_exports__, __vue_options__
var __vue_styles__ = {}
/* styles */
/* template */
var __vue_template__ = __webpack_require__(18)
__vue_options__ = __vue_exports__ = __vue_exports__ || {}
if (
typeof __vue_exports__.default === "object" ||
typeof __vue_exports__.default === "function"
) {
if (Object.keys(__vue_exports__).some(function (key) { return key !== "default" && key !== "__esModule" })) {console.error("named exports are not supported in *.vue files.")}
__vue_options__ = __vue_exports__ = __vue_exports__.default
}
if (typeof __vue_options__ === "function") {
__vue_options__ = __vue_options__.options
}
__vue_options__.__file = "/Users/Alexandre/Code/Github/nuxt.js/examples/hello-world/pages/about.vue"
__vue_options__.render = __vue_template__.render
__vue_options__.staticRenderFns = __vue_template__.staticRenderFns
__vue_options__._scopeId = "data-v-d30325b8"
if (__vue_options__.functional) {console.error("[vue-loader] about.vue: functional components are not supported and should be defined in plain js files using render functions.")}
module.exports = __vue_exports__
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
var __vue_exports__, __vue_options__
var __vue_styles__ = {}
/* styles */
/* template */
var __vue_template__ = __webpack_require__(16)
__vue_options__ = __vue_exports__ = __vue_exports__ || {}
if (
typeof __vue_exports__.default === "object" ||
typeof __vue_exports__.default === "function"
) {
if (Object.keys(__vue_exports__).some(function (key) { return key !== "default" && key !== "__esModule" })) {console.error("named exports are not supported in *.vue files.")}
__vue_options__ = __vue_exports__ = __vue_exports__.default
}
if (typeof __vue_options__ === "function") {
__vue_options__ = __vue_options__.options
}
__vue_options__.__file = "/Users/Alexandre/Code/Github/nuxt.js/examples/hello-world/pages/index.vue"
__vue_options__.render = __vue_template__.render
__vue_options__.staticRenderFns = __vue_template__.staticRenderFns
__vue_options__._scopeId = "data-v-9393702e"
if (__vue_options__.functional) {console.error("[vue-loader] index.vue: functional components are not supported and should be defined in plain js files using render functions.")}
module.exports = __vue_exports__
/***/ },
/* 13 */
/***/ function(module, exports, __webpack_require__) {
var __vue_exports__, __vue_options__
var __vue_styles__ = {}
/* styles */
/* script */
__vue_exports__ = __webpack_require__(7)
/* template */
var __vue_template__ = __webpack_require__(15)
__vue_options__ = __vue_exports__ = __vue_exports__ || {}
if (
typeof __vue_exports__.default === "object" ||
typeof __vue_exports__.default === "function"
) {
if (Object.keys(__vue_exports__).some(function (key) { return key !== "default" && key !== "__esModule" })) {console.error("named exports are not supported in *.vue files.")}
__vue_options__ = __vue_exports__ = __vue_exports__.default
}
if (typeof __vue_options__ === "function") {
__vue_options__ = __vue_options__.options
}
__vue_options__.__file = "/Users/Alexandre/Code/Github/nuxt.js/pages/_error.vue"
__vue_options__.render = __vue_template__.render
__vue_options__.staticRenderFns = __vue_template__.staticRenderFns
__vue_options__._scopeId = "data-v-51a55454"
if (__vue_options__.functional) {console.error("[vue-loader] _error.vue: functional components are not supported and should be defined in plain js files using render functions.")}
module.exports = __vue_exports__
/***/ },
/* 14 */
/***/ function(module, exports) {
module.exports={render:function (){with(this) {
return _h('div', {
staticClass: "progress",
style: ({
'width': percent + '%',
'height': height,
'background-color': canSuccess ? color : failedColor,
'opacity': show ? 1 : 0
})
})
}},staticRenderFns: []}
/***/ },
/* 15 */
/***/ function(module, exports) {
module.exports={render:function (){with(this) {
return _h('div', {
staticClass: "error-page"
}, [_h('div', [_h('h1', {
staticClass: "error-code"
}, [_s(error.statusCode)]), " ", _h('div', {
staticClass: "error-wrapper-message"
}, [_h('h2', {
staticClass: "error-message"
}, [_s(error.message)])]), " ", (error.statusCode === 404) ? _h('p', [_h('router-link', {
staticClass: "error-link",
attrs: {
"to": "/"
}
}, ["Back to the home page"])]) : _e()])])
}},staticRenderFns: []}
/***/ },
/* 16 */
/***/ function(module, exports) {
module.exports={render:function (){with(this) {
return _h('div', {
staticClass: "container"
}, [_m(0), " ", _m(1), " ", _h('p', [_h('router-link', {
attrs: {
"to": "/about"
}
}, ["About"])])])
}},staticRenderFns: [function (){with(this) {
return _h('img', {
attrs: {
"src": "/static/nuxt.png"
}
})
}},function (){with(this) {
return _h('h2', ["Hello World."])
}}]}
/***/ },
/* 17 */
/***/ function(module, exports) {
module.exports={render:function (){with(this) {
return _h('div', {
attrs: {
"id": "app"
}
}, [_h('nuxt-loading', {
ref: "loading"
}), " ", (!err) ? _h('router-view') : _e(), " ", (err) ? _h('nuxt-error', {
attrs: {
"error": err
}
}) : _e()])
}},staticRenderFns: []}
/***/ },
/* 18 */
/***/ function(module, exports) {
module.exports={render:function (){with(this) {
return _h('div', {
staticClass: "container"
}, [_m(0), " ", _m(1), " ", _h('p', [_h('router-link', {
attrs: {
"to": "/"
}
}, ["Home"])])])
}},staticRenderFns: [function (){with(this) {
return _h('img', {
attrs: {
"src": "/static/nuxt.png"
}
})
}},function (){with(this) {
return _h('h2', ["About"])
}}]}
/***/ },
/* 19 */
/***/ function(module, exports) {
module.exports = require("vue-meta");
/***/ },
/* 20 */
/***/ function(module, exports) {
module.exports = require("vue-router");
/***/ },
/* 21 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _vue = __webpack_require__(0);
var _vue2 = _interopRequireDefault(_vue);
var _lodash = __webpack_require__(4);
var _index = __webpack_require__(1);
var _utils = __webpack_require__(2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var debug = __webpack_require__(3)('nuxt:render');
var isDev = false;
var _app = new _vue2.default(_index.app);
// This exported function will be called by `bundleRenderer`.
// This is where we perform data-prefetching to determine the
// state of our application before actually rendering it.
// Since data fetching is async, this function is expected to
// return a Promise that resolves to the app instance.
exports.default = function (context) {
// set router's location
_index.router.push(context.url);
// Add route to the context
context.route = _index.router.currentRoute;
// Add meta infos
context.meta = _app.$meta();
// Add store to the context
// Nuxt object
context.nuxt = { data: [], error: null };
// Call data & fecth hooks on components matched by the route.
var Components = (0, _utils.getMatchedComponents)(context.route);
if (!Components.length) {
context.nuxt.error = _app.error({ statusCode: 404, message: 'This page could not be found.', url: context.route.path });
return Promise.resolve(_app);
}
return Promise.all(Components.map(function (Component) {
var promises = [];
if (Component.data && typeof Component.data === 'function') {
Component._data = Component.data;
var promise = Component.data((0, _utils.getContext)(context));
if (!(promise instanceof Promise)) promise = Promise.resolve(promise);
promise.then(function (data) {
Component.data = function () {
return data;
};
});
promises.push(promise);
} else {
promises.push(null);
}
if (Component.fetch) {
promises.push(Component.fetch((0, _utils.getContext)(context)));
}
return Promise.all(promises);
})).then(function (res) {
// datas are the first row of each
context.nuxt.data = res.map(function (tab) {
return tab[0];
});
return _app;
}).catch(function (error) {
context.nuxt.error = _app.error(error);
return _app;
});
};
/***/ }
/******/ ]);

View File

@ -0,0 +1,2 @@
.container[data-v-d30325b8]{font-family:serif;margin-top:200px;text-align:center}.container[data-v-9393702e]{font-family:sans-serif;margin-top:200px;text-align:center}.error-page[data-v-51a55454]{color:#000;background:#fff;top:0;bottom:0;left:0;right:0;position:absolute;font-family:SF UI Text,Helvetica Neue,Lucida Grande;text-align:center;padding-top:20%}.error-code[data-v-51a55454]{display:inline-block;font-size:24px;font-weight:500;vertical-align:top;border-right:1px solid rgba(0,0,0,.298039);margin:0 20px 0 0;padding:10px 23px}.error-wrapper-message[data-v-51a55454]{display:inline-block;text-align:left;line-height:49px;height:49px;vertical-align:middle}.error-message[data-v-51a55454]{font-size:14px;font-weight:400;margin:0;padding:0}.error-link[data-v-51a55454]{color:#42b983;font-weight:400;text-decoration:none;font-size:14px}.progress[data-v-3223f20f]{position:fixed;top:0;left:0;right:0;height:2px;width:0;transition:width .2s,opacity .4s;opacity:1;background-color:#efc14e;z-index:999999}
/*# sourceMappingURL=style.css.map*/

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","file":"style.css","sourceRoot":""}

File diff suppressed because one or more lines are too long

13
examples/hello-world/dist/about.html vendored Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html data-vue-meta-server-rendered>
<html>
<head>
<title data-vue-meta="true">Untitled</title>
<link rel="stylesheet" href="/_nuxt/style.css">
</head>
<body>
<div id="app" server-rendered="true"><div class="progress" style="width:0%;height:2px;background-color:black;opacity:0;" data-v-3223f20f></div> <div class="container" data-v-d30325b8><img src="/static/nuxt.png" data-v-d30325b8> <h2 data-v-d30325b8>About</h2> <p data-v-d30325b8><a href="/" class="router-link-active" data-v-d30325b8>Home</a></p></div> <!----></div>
<script type="text/javascript" defer>window.__NUXT__={"data":[null],"error":null}</script>
<script src="/_nuxt/vendor.bundle.js" defer></script>
<script src="/_nuxt/nuxt.bundle.js" defer></script>
</body>
</html>

13
examples/hello-world/dist/index.html vendored Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html data-vue-meta-server-rendered>
<html>
<head>
<title data-vue-meta="true">Untitled</title>
<link rel="stylesheet" href="/_nuxt/style.css">
</head>
<body>
<div id="app" server-rendered="true"><div class="progress" style="width:0%;height:2px;background-color:black;opacity:0;" data-v-3223f20f></div> <div class="container" data-v-9393702e><img src="/static/nuxt.png" data-v-9393702e> <h2 data-v-9393702e>Hello World.</h2> <p data-v-9393702e><a href="/about" class="" data-v-9393702e>About</a></p></div> <!----></div>
<script type="text/javascript" defer>window.__NUXT__={"data":[null],"error":null}</script>
<script src="/_nuxt/vendor.bundle.js" defer></script>
<script src="/_nuxt/nuxt.bundle.js" defer></script>
</body>
</html>

BIN
examples/hello-world/dist/nuxt.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -1,17 +1,21 @@
'use strict' 'use strict'
// const fs = require('fs') const fs = require('fs-extra')
const { ncp } = require('ncp') const co = require('co')
// const debug = require('debug')('nuxt:generate') const pify = require('pify')
const debug = require('debug')('nuxt:generate')
const _ = require('lodash') const _ = require('lodash')
const { resolve } = require('path') const { resolve, join } = require('path')
const copy = pify(fs.copy)
const remove = pify(fs.remove)
const writeFile = pify(fs.writeFile)
const defaults = { const defaults = {
dir: 'dist', dir: 'dist',
routeParams: {} routeParams: {}
} }
module.exports = function * () { module.exports = function () {
/* /*
** Set variables ** Set variables
*/ */
@ -20,35 +24,42 @@ module.exports = function * () {
var srcBuiltPath = resolve(this.dir, '.nuxt', 'dist') var srcBuiltPath = resolve(this.dir, '.nuxt', 'dist')
var distPath = resolve(this.dir, this.options.generate.dir) var distPath = resolve(this.dir, this.options.generate.dir)
var distNuxtPath = resolve(distPath, '_nuxt') var distNuxtPath = resolve(distPath, '_nuxt')
/* co(function * () {
** Copy static and built files /*
*/ ** Clean destination folder
ncp(srcStaticPath, distNuxtPath, function (err) { */
if (err) { try {
return console.log(err) yield remove(distPath)
} debug('Destination folder cleaned')
console.log('[nuxt] Static files copied') } catch (e) {}
/*
** Copy static and built files
*/
yield [
copy(srcStaticPath, distPath),
copy(srcBuiltPath, distNuxtPath)
]
debug('Static & build files copied')
}) })
ncp(srcBuiltPath, distNuxtPath, function (err) { .then(() => {
if (err) { /*
return console.log(err) ** Generate html files from routes
} */
console.log('[nuxt] Built files copied') var promises = []
}) this.options.routes.forEach((route) => {
/* var promise = this.renderRoute(route.path)
** Generate html files from routes .then((html) => {
*/ var path = route.path
var promises = [] path += path[path.length - 1] === '/' ? 'index.html' : '.html'
this.options.routes.forEach((route) => { debug('Generate file : ' + path)
var promise = this.renderRoute(route.path).then((html) => { path = join(distPath, path)
return { return writeFile(path, html, 'utf8')
path: route.path, })
html promises.push(promise)
}
}) })
promises.push(promise) return Promise.all(promises)
})
.then((pages) => {
debug('HTML Files generated')
}) })
// Promise.all(promises).then((page) => {
// verifier erreur
// })
} }

View File

@ -31,12 +31,12 @@
"es6-promise": "^4.0.5", "es6-promise": "^4.0.5",
"extract-text-webpack-plugin": "2.0.0-beta.4", "extract-text-webpack-plugin": "2.0.0-beta.4",
"file-loader": "^0.9.0", "file-loader": "^0.9.0",
"fs-extra": "^1.0.0",
"glob-promise": "^1.0.6", "glob-promise": "^1.0.6",
"hash-sum": "^1.0.2", "hash-sum": "^1.0.2",
"lodash": "^4.16.6", "lodash": "^4.16.6",
"lru-cache": "^4.0.1", "lru-cache": "^4.0.1",
"mkdirp-then": "^1.2.0", "mkdirp-then": "^1.2.0",
"ncp": "^2.0.0",
"pify": "^2.3.0", "pify": "^2.3.0",
"serialize-javascript": "^1.3.0", "serialize-javascript": "^1.3.0",
"serve-static": "^1.11.1", "serve-static": "^1.11.1",