Skip to content

Instantly share code, notes, and snippets.

@wickedst
Last active May 27, 2022 16:47
Show Gist options
  • Save wickedst/a65bf76c52e812539abc2ee7c16408aa to your computer and use it in GitHub Desktop.
Save wickedst/a65bf76c52e812539abc2ee7c16408aa to your computer and use it in GitHub Desktop.
Now V2 next.js config for postlight/headless-wp-starter
// just adds target: "serverless"
const path = require('path');
const glob = require('glob');
module.exports = {
webpack: config => {
config.module.rules.push(
{
test: /\.(css|scss)/,
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]',
},
},
{
test: /\.css$/,
use: ['babel-loader', 'raw-loader', 'postcss-loader'],
},
{
test: /\.s(a|c)ss$/,
use: [
'babel-loader',
'raw-loader',
'postcss-loader',
{
loader: 'sass-loader',
options: {
includePaths: ['styles', 'node_modules']
.map(d => path.join(__dirname, d))
.map(g => glob.sync(g))
.reduce((a, c) => a.concat(c), []),
},
},
],
},
);
return config;
},
target: "serverless"
};
// uses next routes config instead of express server.js (server.js still used for development)
{
"version": 2,
"name": "headless-wp-starter",
"builds": [
{ "src": "next.config.js", "use": "@now/next" }
],
"routes": [
{ "src": "/post/(?<slug>[^/]+)$", "dest": "/post?slug=$slug&apiRoute=post" },
{ "src": "/page/(?<slug>[^/]+)$", "dest": "/page?slug=$slug&apiRoute=page" },
{ "src": "/(.*)$", "dest": "/$1" }
],
"env": {
"NODE_ENV": "production"
}
}
{
"name": "frontend",
"version": "2.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "next build",
"now-build": "next build",
"start": "CHOKIDAR_USEPOLLING=true node server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.4",
"isomorphic-unfetch": "^3.0.0",
"next": "7.0.2",
"react": "^16.7.0",
"wpapi": "^1.2.1",
"autoprefixer": "9.4.7",
"postcss-easy-import": "^3.0.0",
"glob": "^7.1.3",
"axios": "^0.18.0"
},
"devDependencies": {
"eslint": "^5.13.0",
"babel-eslint": "^10.0.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.12.4",
"babel-plugin-module-resolver": "^3.1.3",
"babel-plugin-wrap-in-js": "^1.1.0",
"node-sass": "^4.11.0",
"normalize.css": "^8.0.1",
"postcss-loader": "^3.0.0",
"raw-loader": "^1.0.0",
"react-dom": "^16.7.0",
"sass-loader": "^7.1.0",
"webpack": "^4.29.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment