Skip to content
This repository was archived by the owner on Jan 16, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/build
.vagrant
.idea
15 changes: 15 additions & 0 deletions gh-pages-deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require('shelljs/global');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add shelljs to the package.json


if (!which('git')) {
echo('Sorry, this script requires git to be available on the command line');
exit(1);
}

exec('git stash');
var commitDate = new Date().toString().replace(/\s/g,'_').replace(/\W/g, '');
cp('-f', 'lib/staticSite.html', 'build/public/index.html');
exec('git branch gh-pages');
exec('git checkout gh-pages');
cp('-rf', './build/public/*', '.');
exec('git add .');
exec('git commit -m "Automated commit on' + commitDate+ '"');
12 changes: 12 additions & 0 deletions lib/staticSite.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="main.css"/>
</head>
<body>
<div id="content"></div>
</body>
<script src="main.js"></script>
</html>

23 changes: 13 additions & 10 deletions make-webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ module.exports = function(options) {
if(options.commonsChunk) {
plugins.push(new webpack.optimize.CommonsChunkPlugin("commons", "commons.js" + (options.longTermCaching && !options.prerender ? "?[chunkhash]" : "")));
}
var asyncLoader = {
test: require("./app/route-handlers/async").map(function(name) {
return path.join(__dirname, "app", "route-handlers", name);
}),
loader: options.prerender ? "react-proxy-loader/unavailable" : "react-proxy-loader"
};



if(!options.staticSite){
var asyncLoader = {
test: require("./app/route-handlers/async").map(function(name) {
return path.join(__dirname, "app", "route-handlers", name);
}),
loader: options.prerender ? "react-proxy-loader/unavailable" : "react-proxy-loader"
};
}
Object.keys(stylesheetLoaders).forEach(function(ext) {
var stylesheetLoader = stylesheetLoaders[ext];
if(Array.isArray(stylesheetLoader)) stylesheetLoader = stylesheetLoader.join("!");
Expand Down Expand Up @@ -135,12 +135,15 @@ module.exports = function(options) {
);
}

var loaderStart = typeof asyncLoader !== 'undefined' ? [asyncLoader] : [];
return {
entry: entry,
output: output,
target: options.prerender ? "node" : "web",
module: {
loaders: [asyncLoader].concat(loadersByExtension(loaders)).concat(loadersByExtension(stylesheetLoaders)).concat(additionalLoaders)
loaders: loaderStart.concat(loadersByExtension(loaders))
.concat(loadersByExtension(stylesheetLoaders))
.concat(additionalLoaders)
},
devtool: options.devtool,
debug: options.debug,
Expand All @@ -163,4 +166,4 @@ module.exports = function(options) {
}
}
};
};
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dev-server": "webpack-dev-server --config webpack-dev-server.config.js --progress --colors --port 2992 --inline",
"hot-dev-server": "webpack-dev-server --config webpack-hot-dev-server.config.js --hot --progress --colors --port 2992 --inline",
"build": "webpack --config webpack-production.config.js --progress --profile --colors",
"build-static": "webpack --config webpack-static-site.config.js --progress --profile --colors && node gh-pages-deploy.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you split it into two tasks. build-static and deploy-static. Maybe someone want to test the static page before deploying... deplay-static should call npm run build-static

"start-dev": "node lib/server-development",
"start": "node lib/server-production"
},
Expand Down
13 changes: 13 additions & 0 deletions webpack-static-site.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = [
require("./make-webpack-config")({
longTermCaching: true,
separateStylesheet: true,
minimize: true,
staticSite:true
}),
require("./make-webpack-config")({
prerender: true,
minimize: true,
staticSite:true
})
];