Last active
February 21, 2017 11:23
-
-
Save fabienheureux/f52124f8a1d985ac0890ab99e678766c to your computer and use it in GitHub Desktop.
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
Show hidden characters
{ | |
"plugins": [ | |
[ | |
"wrap-in-js", | |
{ | |
"extensions": ["css$"] | |
} | |
] | |
], | |
"presets": [ | |
"next/babel" | |
], | |
"ignore": [] | |
} |
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
const express = require('express') | |
const { parse } = require('url') | |
const next = require('next') | |
const dev = process.env.NODE_ENV !== 'production' | |
const app = next({ dir: '.', dev }) | |
const handle = app.getRequestHandler() | |
app.prepare() | |
.then(() => { | |
const server = express() | |
server.set('port', (process.env.PORT || 3000)); | |
server.get('/', (req, res) => { | |
return app.render(req, res, '/homepage') | |
}) | |
server.get('/page/:slug', (req, res) => { | |
const queryParams = { slug: req.params.slug } | |
return app.render(req, res, '/page', queryParams) | |
}) | |
server.get('/theme/:slug', (req, res) => { | |
const queryParams = { slug: req.params.slug } | |
return app.render(req, res, '/theme', queryParams) | |
}) | |
server.get('/theme/:id/:slug', (req, res) => { | |
const queryParams = { id: req.params.id, slug: req.params.slug } | |
return app.render(req, res, '/racine', queryParams) | |
}) | |
server.get('*', (req, res) => { | |
return handle(req, res) | |
}) | |
server.listen(3000, (err) => { | |
if (err) throw err | |
console.log('> Ready on http://localhost:3000') | |
}) | |
}) |
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
module.exports = { | |
webpack: (config, { dev }) => { | |
config.module.rules.push( | |
{ | |
test: /\.(css)/, | |
loader: 'emit-file-loader', | |
options: { | |
name: 'dist/[path][name].[ext]' | |
} | |
} | |
, | |
{ | |
test: /\.css$/, | |
loader: 'babel-loader!raw-loader' | |
} | |
) | |
return config | |
} | |
} |
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
{ | |
"name": "kub-clientt", | |
"version": "1.0.0", | |
"main": "index.js", | |
"repository": {}, | |
"author": "Fabien LF ", | |
"license": "MIT", | |
"scripts": { | |
"dev": "node index.js", | |
"build": "next build", | |
"start": "NODE_ENV=production node index.js" | |
}, | |
"dependencies": { | |
"babel-plugin-wrap-in-js": "^1.1.1", | |
"express": "^4.14.1", | |
"isomorphic-fetch": "^2.2.1", | |
"next": "2", | |
"nprogress": "^0.2.0", | |
"raw-loader": "^0.5.1", | |
"react": "^15.4.2", | |
"react-dom": "^15.4.2", | |
"react-masonry-component": "^5.0.3", | |
"react-sizeme": "^2.2.0", | |
"request": "^2.79.0", | |
"request-promise": "^4.1.1", | |
"request-promise-native": "^1.0.3", | |
"styled-components": "^1.4.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment