Skip to content

Commit

Permalink
better long-term caching
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanflorence committed Mar 14, 2016
1 parent 4ea3a04 commit ff062a4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.25

- Better long term caching

## 0.0.24

- Fixed server route regression
Expand Down
3 changes: 2 additions & 1 deletion create-react-project/blueprint/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
module.exports = require('react-project/webpack')
module.exports = require('react-project/webpack')

9 changes: 1 addition & 8 deletions modules/PublicServerAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import { log } from './LogUtils'
import { PORT, APP_PATH, PUBLIC_DIR, SERVER_RENDERING } from './Constants'
import ErrorMessage from './ErrorMessage'

const PROD = process.env.NODE_ENV === 'production'

export function createServer(getApp) {
const server = express()
const webpackStats = getWebpackStats()
Expand Down Expand Up @@ -73,16 +71,11 @@ export function createServer(getApp) {
return server
}

function addProductionOnlyMiddleware(server) {
if (PROD) {
}
}

function addMiddleware(server) {
if (process.env.NODE_ENV === 'production') {
server.use(morgan('combined'))
server.use(compression())
server.use(express.static(PUBLIC_DIR))
server.use(express.static(PUBLIC_DIR, { maxAge: 31536000 }))
} else {
server.use(morgan('dev'))
}
Expand Down
8 changes: 4 additions & 4 deletions modules/webpack.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const REFRESH = process.env.AUTO_RELOAD === 'refresh'
const PROD = process.env.NODE_ENV === 'production'
// can't do HMR with SERVER_RENDERING because of ExtractTextPlugin
const HOT = !PROD && !SERVER_RENDERING && process.env.AUTO_RELOAD === 'hot'
const HASH8 = '[hash:8]'
const HASH = '[chunkHash]'

function getPublicPath() {
return PROD ? PUBLIC_PATH : `http://${DEV_HOST}:${DEV_PORT}/`
Expand Down Expand Up @@ -83,7 +83,7 @@ function getCSSLoader() {
}

function getFileName() {
return PROD ? `${HASH8}.js` : '[name].js'
return PROD ? `${HASH}.js` : '[name].js'
}

function getDevTool() {
Expand Down Expand Up @@ -127,12 +127,12 @@ function getEntry() {
function getPlugins() {

const plugins = [
new webpack.optimize.CommonsChunkPlugin('_vendor', 'vendor.js')
new webpack.optimize.CommonsChunkPlugin('_vendor', PROD ? `vendor-${HASH}.js` : 'vendor.js')
]

if (PROD) {
plugins.push(
new ExtractTextPlugin(`${HASH8}.css`),
new ExtractTextPlugin(`${HASH}.css`),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin()
Expand Down

0 comments on commit ff062a4

Please sign in to comment.