Skip to content
Permalink
Browse files

build static pages to public

updated web pack config and new entry point for building static pages and publicServer to serve results. Moved require.contexts in paths.js inside functions so they don't break when run outside web pack
  • Loading branch information...
BradDenver committed Jan 13, 2015
1 parent 0b56e67 commit 09a2d3dee7305f21e5071eb493fe1473676a00ad
@@ -0,0 +1,41 @@
process.env.NODE_ENV='production';
var fs = require('fs'),
mkdirp = require('mkdirp'),
page = require('./dev/bundleStaticPage.js'),
paths = require('./paths'),
webpack = require('webpack'),
config = require('./webpack.config');

webpack(config[2], function(err, stats) {

if(err) {

console.log(err);

} else {

var assets = 'public/assets';
mkdirp.sync(assets);
fs.writeFileSync(assets + '/pure.css', fs.readFileSync('bower_components/pure/pure.css'));
fs.writeFileSync(assets + '/style.css', fs.readFileSync('elements/style.css'));

for(var path in paths.allPaths()) {
if(path!=='posts') {
mkdirp.sync('public' + path);
fs.writeFileSync('public' + path + '/index.html', page(path));
console.log(path);
}
}

mkdirp.sync('public/blog');
for(var post in paths.allPosts()) {
fs.writeFileSync('public/blog/' + post + '.html', page('/blog/' + post));
console.log('blog/' + post + '.html');
}

}

console.log('build complete');

});

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -158,11 +158,16 @@ module.exports =

render: function() {
var script = (process.env.NODE_ENV!=='production') ? React.createElement("script", {src: "http://localhost:3000/scripts/bundle.js"}) : '';
var style = (process.env.NODE_ENV==='production') ? React.createElement("link", {rel: "stylesheet", href: "/assets/pure.css"}) : '';
var style2 = (process.env.NODE_ENV==='production') ? React.createElement("link", {rel: "stylesheet", href: "/assets/style.css"}) : '';

var title = this.getPathMeta('title') + ' - React Static Site';
return (
React.createElement("html", null,
React.createElement("head", null,
React.createElement("title", null, title)
React.createElement("title", null, title),
style,
style2
),
React.createElement("body", null,
React.createElement("div", {id: "layout"},
@@ -9512,9 +9517,6 @@ module.exports =

};

var pageReq = __webpack_require__(130),
postReq = __webpack_require__(131);

module.exports = {
allPaths: function() {
return paths;
@@ -9523,10 +9525,16 @@ module.exports =
return paths.posts;
},
pageForPath: function(path) {
return pageReq('./' + paths[path].page);
return this.pageReq()('./' + paths[path].page);
},
postForPath: function(path) {
return postReq('./' + paths.posts[path].md);
return this.postReq()('./' + paths.posts[path].md);
},
pageReq: function() {
return __webpack_require__(130);
},
postReq: function() {
return __webpack_require__(131);
}
};

Oops, something went wrong.

0 comments on commit 09a2d3d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.