Skip to content

Instantly share code, notes, and snippets.

@wickedst
Last active May 27, 2022 16:47

Revisions

  1. wickedst revised this gist Mar 7, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    "main": "index.js",
    "scripts": {
    "build": "next build",
    "now-build": "next build"
    "now-build": "next build",
    "start": "CHOKIDAR_USEPOLLING=true node server.js"
    },
    "keywords": [],
  2. wickedst revised this gist Mar 7, 2019. No changes.
  3. wickedst revised this gist Mar 7, 2019. 2 changed files with 28 additions and 22 deletions.
    48 changes: 26 additions & 22 deletions next.config.js
    Original file line number Diff line number Diff line change
    @@ -1,37 +1,41 @@
    const path = require('path')
    const glob = require('glob')
    // just adds target: "serverless"

    const path = require('path');
    const glob = require('glob');

    module.exports = {
    webpack: (config, { dev }) => {
    webpack: config => {
    config.module.rules.push(
    {
    test: /\.(css|scss)/,
    loader: 'emit-file-loader',
    options: {
    name: 'dist/[path][name].[ext]'
    }
    }
    ,
    name: 'dist/[path][name].[ext]',
    },
    },
    {
    test: /\.css$/,
    use: ['babel-loader', 'raw-loader', 'postcss-loader']
    }
    ,
    use: ['babel-loader', 'raw-loader', 'postcss-loader'],
    },
    {
    test: /\.s(a|c)ss$/,
    use: ['babel-loader', 'raw-loader', 'postcss-loader',
    { loader: 'sass-loader',
    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
    .map(d => path.join(__dirname, d))
    .map(g => glob.sync(g))
    .reduce((a, c) => a.concat(c), []),
    },
    },
    ],
    },
    );
    return config;
    },
    target: "serverless"
    }
    };
    2 changes: 2 additions & 0 deletions now.json
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    // uses next routes config instead of express server.js (server.js still used for development)

    {
    "version": 2,
    "name": "headless-wp-starter",
  4. wickedst revised this gist Mar 7, 2019. 2 changed files with 59 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions now.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    {
    "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"
    }
    }
    44 changes: 44 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    {
    "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"
    }
    }
  5. wickedst revised this gist Mar 7, 2019. No changes.
  6. wickedst created this gist Mar 7, 2019.
    37 changes: 37 additions & 0 deletions next.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    const path = require('path')
    const glob = require('glob')

    module.exports = {
    webpack: (config, { dev }) => {
    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"
    }