Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
試加,毋過失敗 #196
Browse files Browse the repository at this point in the history
  • Loading branch information
sih4sing5hong5 committed Aug 11, 2016
1 parent 6b27791 commit d5c68ff
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"description": "itaigi",
"scripts": {
"start": "node devServer.js",
"production": "NODE_ENV=production webpack -p --progress --config webpack.config.js && node prerender",
"server": "node prerender",
"test": "jscs *.js src/",
"reformat": "jscs -x *.js src/",
"build": "mkdir -p build;rm -f build/* && NODE_ENV=production webpack --config webpack.config.prod.js && cp index.html favicons/* build/ && cp index.html build/404.html",
Expand Down
17 changes: 17 additions & 0 deletions prerender/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var express = require("express");
var path = require("path");
var page = require("./bundle.js");

var app = express();

app.use(express.static(path.join(__dirname, "..", "build")));

var stats = require("./stats.generated.json");

app.get("/", function(req, res) {
res.end(page(req, stats.assetsByChunkName.main));
});

var server = app.listen(3000, function() {
console.log('Listening on port %d', server.address().port);
});
54 changes: 54 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var path = require('path');
var webpack = require('webpack');

module.exports = {
devtool: 'source-map',
entry: [
'./src',
],

target: "node",
output: {
path: path.join(__dirname, 'prerender'),
filename: 'bundle.js',
publicPath: '/',
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
"global.GENTLY": false
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false,
},
}),
],
resolve: {
extensions: ['', '.js', '.jsx'],
},
module: {
loaders: [
{
test: /\.jsx?/,
loaders: ['babel', 'strict'],
include: path.join(__dirname, 'src'),
},
{
test: /\.css$/,
loader: 'style-loader!css-loader!postcss-loader',
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url-loader?limit=1',
},
{
test: /\.json$/,
loader: 'json-loader',
},
],
},
};

0 comments on commit d5c68ff

Please sign in to comment.