-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* master: (21 commits) improved syntax for including styles fixed erikras/react-redux-universal-hot-example#77 added apology for #60 in the README linted url-loader fix for images switched back to file-loader to avoid error from requireServerImage() fixes #39 Works on mac now Added better-npm-run to allow setting env-vars on all platforms fixed cat pic on server render minor grammar and js style tweak to README added url-loader to production webpack, too merged PR #67. lint-corrected merge. added obligatory cat pic. changed to use url-loader to encode small images. made pass lint incorporated PR #67 and added some comments to promise chaining in createTransitionHook() util import should be in single line. correct the , to , sorry for my keyboard. remove a space :P update README. correct the util error :P add the image server render example to the logo.png. ...
- Loading branch information
Showing
18 changed files
with
190 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
webpack/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules/ | |
dist/ | ||
*.iml | ||
webpack-stats.json | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
import path from 'path'; | ||
const readStats = () => { | ||
// don't cache the `webpack-stats.json` on dev so we read the file on each request. | ||
// on production, use simple `require` to cache the file | ||
const stats = require('../webpack-stats.json'); | ||
if (__DEVELOPMENT__) { | ||
delete require.cache[require.resolve('../webpack-stats.json')]; | ||
} | ||
return stats; | ||
} | ||
|
||
export function requireServerCss(cssPath) { | ||
if (__CLIENT__) { | ||
throw new Error('image-resolver called on browser'); | ||
} | ||
return readStats().css.modules[cssPath.slice(__dirname.length)]; | ||
} | ||
|
||
export function requireServerImage(imagePath) { | ||
if (!imagePath) { | ||
return ''; | ||
} | ||
if (__CLIENT__) { | ||
throw new Error('server-side only resolver called on client'); | ||
} | ||
const images = readStats().images; | ||
if (!images) { | ||
return ''; | ||
} | ||
|
||
// Find the correct image | ||
const regex = new RegExp(`${imagePath}$`); | ||
const image = images.find(img => regex.test(img.original)); | ||
|
||
const pathToSrc = path.resolve(__dirname, '.'); | ||
// Serve image. | ||
if (image) return image.compiled; | ||
|
||
export function relativeToSrc(value) { | ||
return value.slice(pathToSrc.length); | ||
// Serve a not-found asset maybe? | ||
return ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.