diff --git a/.gitignore b/.gitignore index 5b2cd33..189366b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules /build .vagrant +.idea diff --git a/lib/static-build-assets/build-static.js b/lib/static-build-assets/build-static.js new file mode 100644 index 0000000..1737863 --- /dev/null +++ b/lib/static-build-assets/build-static.js @@ -0,0 +1,7 @@ +require('shelljs/global'); + +exec('git stash'); +cp('-f', 'lib/static-build-assets/staticSite.html', 'build/public/index.html'); +exec('git branch gh-pages'); +exec('git checkout gh-pages'); +cp('-rf', './build/public/*', '.'); diff --git a/lib/static-build-assets/staticSite.html b/lib/static-build-assets/staticSite.html new file mode 100644 index 0000000..70cba71 --- /dev/null +++ b/lib/static-build-assets/staticSite.html @@ -0,0 +1,12 @@ + + + + + + + +
+ + + + diff --git a/lib/staticSite.html b/lib/staticSite.html new file mode 100644 index 0000000..70cba71 --- /dev/null +++ b/lib/staticSite.html @@ -0,0 +1,12 @@ + + + + + + + +
+ + + + diff --git a/make-webpack-config.js b/make-webpack-config.js index 2aa2410..dc9a8b3 100644 --- a/make-webpack-config.js +++ b/make-webpack-config.js @@ -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("!"); @@ -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, @@ -163,4 +166,4 @@ module.exports = function(options) { } } }; -}; +}; \ No newline at end of file diff --git a/package.json b/package.json index 6ac3bee..299b946 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "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 lib/static-build-assets/build-static.js", + "deploy-static": "npm run build-static && git add . && git commit -m \"Automated commit on `date +%Y-%m-%d:%H:%M:%S`\"", "start-dev": "node lib/server-development", "start": "node lib/server-production" }, @@ -50,6 +52,7 @@ "devDependencies": { "babel-eslint": "^3.0.1", "eslint": "^0.22.0", - "eslint-plugin-react": "^2.2.0" + "eslint-plugin-react": "^2.2.0", + "shelljs": "^0.5.1" } } diff --git a/webpack-static-site.config.js b/webpack-static-site.config.js new file mode 100644 index 0000000..b48421b --- /dev/null +++ b/webpack-static-site.config.js @@ -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 + }) +]; \ No newline at end of file