next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Build error next.js 6.0.0

Open paschaldev opened this issue 8 years ago • 125 comments

I just upgraded to [email protected], I use a custom server, when I try to run dev, I get an error.

npm run dev

> [email protected] dev /Users/foo/gitlab/next-project/backend
> babel-node ./src/server.js

/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
        throw e;
        ^

Error: Plugin 0 specified in "/Users/foo/gitlab/next-project/backend/node_modules/next/babel.js" provided an invalid property of "default" (While processing preset: "/Users/foo/gitlab/next-project/backend/node_modules/next/babel.js")
    at Plugin.init (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/plugin.js:131:13)
    at Function.normalisePlugin (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:152:12)
    at /Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
    at Array.map (<anonymous>)
    at Function.normalisePlugins (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
    at OptionManager.mergeOptions (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
    at /Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
    at /Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/Users/foo/gitlab/next-project/backend/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `babel-node ./src/server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/foo/.npm/_logs/2018-04-30T08_41_09_819Z-debug.log

UPDATE all this passed after upgrading all babel packages to v7

Now this is the new error.... See below for complete error message

ERROR  Failed to compile with 1 errors                                                                                                                                                                                               10:32:07

 error  in ./pages/_document.js

Module build failed: Error: [BABEL] /Users/foo/gitlab/zyombo/backend/pages/_document.js: .value is not a valid Plugin property

paschaldev avatar Apr 30 '18 08:04 paschaldev

I'm curious, which custom server are you using?

DevSpeak avatar Apr 30 '18 09:04 DevSpeak

@DevSpeak express

paschaldev avatar Apr 30 '18 09:04 paschaldev

Update: I updated all my babel dependencies and babel-node to version 7 so it passed now. But now, I get this error.

 ERROR  Failed to compile with 1 errors                                                                                                                                                                                               10:32:07

 error  in ./pages/_document.js

Module build failed: Error: [BABEL] /Users/foo/gitlab/zyombo/backend/pages/_document.js: .value is not a valid Plugin property
    at /Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/config/validation/plugins.js:54:56
    at Array.forEach (<anonymous>)
    at validatePluginObject (/Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/config/validation/plugins.js:52:20)
    at /Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:215:53
    at cachedFunction (/Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/config/caching.js:42:17)
    at loadPluginDescriptor (/Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:207:10)
    at /Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:64:16
    at Array.map (<anonymous>)
    at recurseDescriptors (/Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:63:36)
    at loadFullConfig (/Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:112:6)
    at /Users/foo/gitlab/zyombo/backend/node_modules/@babel/core/lib/transform.js:28:33
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

 @ multi ./pages/_document.js

(node:1878) DeprecationWarning: Module.chunks: Use Module.forEachChunk/mapChunks/getNumberOfChunks/isInChunk/addChunk/removeChunk instead
> Ready on http://localhost:3000
^Cnpm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `babel-node ./src/server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/foo/.npm/_logs/2018-04-30T09_32_10_682Z-debug.log

paschaldev avatar Apr 30 '18 09:04 paschaldev

I have this exact same issue with Babel and Next.

darthchudi avatar Apr 30 '18 10:04 darthchudi

I'm getting ModuleBuildError: Module build failed: Error: Plugin 0 specified in "base" provided an invalid property of "value"

Using a custom server (express), withSass and TypeScript.

djskinner avatar Apr 30 '18 10:04 djskinner

what about Babel config? Examples of the scoped name change:

babel-cli -> @babel/cli babel-core -> @babel/core babel-preset-env -> @babel/preset-env

sea129 avatar Apr 30 '18 10:04 sea129

@sea129 Yeah I have all that.

    "@babel/cli": "^7.0.0-beta.46",
    "@babel/core": "^7.0.0-beta.46",
    "@babel/plugin-proposal-export-default-from": "^7.0.0-beta.46",
    "@babel/preset-env": "^7.0.0-beta.46"

paschaldev avatar Apr 30 '18 11:04 paschaldev

I've had the same problem since https://github.com/zeit/next.js/releases/tag/6.0.0-canary.3

montoias avatar Apr 30 '18 14:04 montoias

please post your .babelrc, next.config.js etc. It's definitely related to which modules you're using in .babelrc, since next by itself is fully compatible with babel 7.

Also please follow the issue template when creating issues, as you can understand it's impossible to help you solve issues you're having based on: "it doesn't work, I get this error"

timneutkens avatar Apr 30 '18 16:04 timneutkens

.babelrc

{
  "env": {
    "development": {
      "presets": [
        "next/babel",
        "@babel/preset-es2017",
        ["@babel/preset-stage-2", {
          decoratorsLegacy: true
        }],
        "@babel/preset-env",
        "@babel/preset-react",
      ],
      "plugins": [
        "@babel/plugin-proposal-class-properties",
        ["transform-inline-environment-variables", {
          "include": [
            "NODE_ENV",
            "GMAPS_API_KEY",
            "EMBED_API_KEY",
          ]
        }],
        ["inline-dotenv", {
          path: './.env'
        }],
      ]
    },
    "production": {
      "presets": [
        "next/babel",
        "@babel/preset-es2017",
        ["@babel/preset-stage-2", {
          decoratorsLegacy: true
        }],
        "@babel/preset-env",
        "@babel/preset-react",
      ],
      "plugins": [
        "@babel/plugin-proposal-class-properties",
        ["inline-dotenv", {
          path: './.env.production'
        }],
        ["transform-inline-environment-variables", {
          "include": [
            "NODE_ENV",
            "GMAPS_API_KEY",
            "EMBED_API_KEY",
          ]
        }],
      ]
    }
  }
}

next.config.js

const webpack = require('webpack');
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const withPlugins = require('next-compose-plugins');
const withCSS = require('@zeit/next-css');
const optimizedImages = require('next-optimized-images');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = withPlugins([
    withCSS,
    optimizedImages,
  ], {
    webpack: (config, options) => {
      const {dev, isServer} = options;

      config.plugins.push(
        new UglifyJsPlugin({
          test: /\.js($|\?)/i
        }),
      );

      config.module.rules.push(
        {
          test: /\.(css|scss)/,
          loader: 'emit-file-loader',
          options: {
            name: 'dist/[path][name].[ext]'
          }
        },
        {
          test: /\.s(a|c)ss$/,
          exclude: /node_modules/,
          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), [])
              }
            }
          ],
        },
        {
          test: /\.js$/,
          enforce: 'pre',
          exclude: /node_modules/,
          loader: 'eslint-loader',
          options: {
            emitWarning: dev,
          },
        },
      )

      if (dev) {
        config.devtool = 'cheap-module-source-map';
      }

      return config;
    },
  });

bryan avatar Apr 30 '18 16:04 bryan

In my case I believe it's related to ts-jest which uses babel 6. Just bootstraped a Next 5 from with-jest-typescript example a few days ago.

joaovieira avatar Apr 30 '18 17:04 joaovieira

@timneutkens Sorry about that

.babelrc

{
	"presets": [
		"next/babel",
	],
	"plugins": [
		"styled-jsx/babel",
		"@babel/plugin-syntax-dynamic-import",
    	["lodash", {"id": ["lodash", "semantic-ui-react"]}]
	],
	"comments": false,
	"compact": true,
	"env": {
    	"development": {

      		"plugins": [
      			"transform-modules",
        		"react-hot-loader/babel"
      		]
    	}
  	}
}

package.json

{
  "name": "frontend-next",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "babel-node ./src/server.js",
    "dev-mon": "nodemon --watch src/components ./src/server.js --exec=babel-node",
    "start": "NODE_ENV=production node  ./src/server.js",
    "build": "next build",
    "analyze": "NODE_ENV=production BUNDLE_ANALYZE=both next build",
    "analyze:browser": "NODE_ENV=production BUNDLE_ANALYZE=browser next build",
    "analyze:server": "NODE_ENV=production BUNDLE_ANALYZE=server next build"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@zeit/next-sass": "0.1.1",
    "apollo-client-preset": "^1.0.8",
    "apollo-link-context": "^1.0.8",
    "autoprefixer": "^8.4.1",
    "babel-loader": "^8.0.0-beta.2",
    "cloudinary-react": "^1.0.6",
    "compression": "^1.7.2",
    "cookie-parser": "^1.4.3",
    "cross-fetch": "^2.1.1",
    "es6-promise": "^4.2.4",
    "graphql": "^0.13.2",
    "graphql-tag": "^2.9.1",
    "immutability-helper": "^2.7.0",
    "lodash": "^4.17.10",
    "moment-mini": "^2.19.4",
    "next": "^6.0.0",
    "next-routes": "^1.4.1",
    "password-maker": "^1.1.3",
    "postcss": "^6.0.22",
    "postcss-colour-functions": "^1.5.2",
    "postcss-conditionals": "^2.1.0",
    "postcss-cssnext": "^3.0.2",
    "postcss-easy-import": "^3.0.0",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.1.4",
    "postcss-simple-vars": "^4.1.0",
    "prop-types": "^15.6.1",
    "react": "^16.3.2",
    "react-apollo": "^2.1.3",
    "react-dates": "^16.6.1",
    "react-document-title": "^2.0.3",
    "react-dom": "^16.3.2",
    "react-fancy-button": "^1.0.5",
    "react-icons-kit": "^1.1.3",
    "react-redux": "^5.0.7",
    "react-redux-loading-bar": "^4.0.4",
    "react-redux-snackbar": "^1.1.0",
    "react-toastify": "^4.0.0-rc.5",
    "react-validify": "^4.0.0",
    "redux": "^4.0.0",
    "redux-promise-middleware": "^5.1.1",
    "redux-thunk": "^2.2.0",
    "semantic-ui-css": "^2.3.1",
    "semantic-ui-react": "^0.79.1",
    "tailwindcss": "^0.5.2",
    "universal-cookie": "^2.1.2"
  },
  "devDependencies": {
    "@babel/cli": "^7.0.0-beta.46",
    "@babel/core": "^7.0.0-beta.46",
    "@babel/node": "^7.0.0-beta.46",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.46",
    "@babel/preset-env": "^7.0.0-beta.46",
    "@zeit/next-bundle-analyzer": "^0.1.1",
    "babel-plugin-lodash": "^3.3.2",
    "babel-plugin-transform-modules": "^0.1.1",
    "classnames": "^2.2.5",
    "emit-file-loader": "0.0.1",
    "extract-text-webpack-plugin": "^3.0.2",
    "node-sass": "^4.9.0",
    "nodemon": "^1.17.2",
    "react-hot-loader": "^4.1.2",
    "redux-devtools-extension": "^2.13.2",
    "redux-logger": "^3.0.6",
    "sass-loader": "^6.0.7",
    "style-loader": "^0.20.3",
    "styled-jsx": "^2.2.6",
    "styled-jsx-css-loader": "^0.3.0",
    "uglifyjs-webpack-plugin": "^1.2.5",
    "webpack-bundle-analyzer": "^2.11.1"
  },
  "peerDependencies": {
    "node-sass": "^4.7.2"
  }
}

next.config.js

const withBundleAnalyzer = require("@zeit/next-bundle-analyzer");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");

const withCSS = require('@zeit/next-css')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const getRoutes = require('./src/routes')

const ExtractTextPlugin = require('extract-text-webpack-plugin')
const ExtractVendorCSS = new ExtractTextPlugin('static/vendor.css')
const util = require('util')

const webpack = require('webpack')
const path = require('path')

module.exports = withBundleAnalyzer( withCSS({

	cssLoaderOptions: {

		importLoaders: 1,
	},
	analyzeServer: ["server", "both"].includes(process.env.BUNDLE_ANALYZE),
  	analyzeBrowser: ["browser", "both"].includes(process.env.BUNDLE_ANALYZE),
  	bundleAnalyzerConfig: {
	    server: {
	    	analyzerMode: 'static',
	    	reportFilename: '../../bundles/server.html'
	    },
	    browser: {
	    	analyzerMode: 'static',
	    	reportFilename: '../bundles/client.html'
	    }
  	},

	webpack(config, options) {

		if( process.env.NODE_ENV == 'production') {
			
			config.plugins.push( 
				new UglifyJSPlugin
				)
		}

		config.module.rules.push( {
			test: /\.scss$/,
			use: ExtractVendorCSS.extract({
				use: [
				{
					loader: 'css-loader', 
					options: {
						importLoaders: 1 
					} 
				},
				'sass-loader'
				]
			}),
			include: /node_modules/
		} );


		//Exclude Semantic UI from css build
		config.module.rules.forEach( rule => {

			if( String(rule.test).match(/\.css/) ){

				rule.exclude = [ /semantic-ui-css/, /react-fancy-button/, /react-dates/, /react-toastify/ ]
			}
		})

		config.module.rules.push({

	        test: /\.css$/,
	        use: [
	        {
	        	loader: 'emit-file-loader',
	            options: {
	            	name: 'dist/[path][name].[ext]',
	            },
	        },
	        {
	            loader: 'babel-loader',
	            options: {
	              babelrc: false,
	              extends: path.resolve(__dirname, './.babelrc'),
	            },
	        },
	        'styled-jsx-css-loader',
	        {
				loader: 'postcss-loader',
				options: {
			    	ident: 'postcss',
			    	plugins: (loader) => [
			      		require('autoprefixer')(),
			      		require('cssnano')({
				            discardComments: { removeAll: true },
				        })
			   		]
			  	}
			}
	        ],
	        include: [ /semantic-ui-css/]
	    });

	    config.module.rules.push( {
			test: /\.css$/,
			use: ExtractVendorCSS.extract({
				use: [
				
				'css-loader'
				]
			}),
			include: [ /react-fancy-button/, /react-dates/, /react-toastify/ ]
		} );

		config.plugins.push( ExtractVendorCSS );

		config.plugins.push( new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/) )

		config.output.publicPath = 'http://localhost:3000/'

		//console.log( util.inspect(config , false, null) );

		return config
	},
	exportPathMap: getRoutes, 
	useFileSystemPublicRoutes: false
}))

paschaldev avatar Apr 30 '18 17:04 paschaldev

@paschaldev if you define settings per environment using env in your .babelrc, you should put all config inside env, and duplicate the config for each environment (except for the differences of course). For example, here's mine:

{
  "env": {
    "development": {
      "presets": ["next/babel"],
      "plugins": [
        ["styled-components", { "ssr": true, "displayName": true, "preprocess": false }],
        ["inline-react-svg"]
      ]
    },
    "production": {
      "presets": ["next/babel"],
      "plugins": [
        ["styled-components", { "ssr": true, "displayName": false, "preprocess": false }],
        ["inline-react-svg"]
      ]
    },
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]],
      "plugins": [
        ["styled-components", { "ssr": true, "displayName": false, "preprocess": false }],
        ["inline-react-svg"]
      ]
    }
  }
}

Yes, it's ugly, but it works.

ghengeveld avatar Apr 30 '18 20:04 ghengeveld

@ghengeveld Did that, same error still

.babelrc

{
	"presets": [
		"next/babel",
	],
	"plugins": [
		"styled-jsx/babel",
		"@babel/plugin-syntax-dynamic-import",
    	["lodash", {"id": ["lodash", "semantic-ui-react"]}]
	],
	"comments": false,
	"compact": true,
	"env": {
    	"development": {

      		"plugins": [
      			"transform-modules",
        		"react-hot-loader/babel"
      		]
    	},
    	"production": {

      		"plugins": [
      			"transform-modules",
        		"react-hot-loader/babel"
      		]
    	},
    	"test": {

      		"plugins": [
      			"transform-modules",
        		"react-hot-loader/babel"
      		]
    	},
  	}
}

paschaldev avatar Apr 30 '18 21:04 paschaldev

There's a lot of things i'm not understanding from your .babelrc 🤔

{
	"presets": [
		"next/babel",
	],
	"plugins": [
		"styled-jsx/babel",
		"@babel/plugin-syntax-dynamic-import",
    	["lodash", {"id": ["lodash", "semantic-ui-react"]}]
	],
	"comments": false,
	"compact": true,
	"env": {
    	"development": {

      		"plugins": [
      			"transform-modules",
        		"react-hot-loader/babel"
      		]
    	},
    	"production": {

      		"plugins": [
      			"transform-modules",
        		"react-hot-loader/babel"
      		]
    	},
    	"test": {

      		"plugins": [
      			"transform-modules",
        		"react-hot-loader/babel"
      		]
    	},
  	}
}

Why are you adding "react-hot-loader/babel", it's part of next/babel.

Same for "styled-jsx/babel", it's included in Next.js by default.

transform-modules stops webpack from codesplitting, making your bundles very big.

@babel/plugin-syntax-dynamic-import => dynamic imports are supported in next.

timneutkens avatar Apr 30 '18 22:04 timneutkens

So you can literally remove the whole "env" block 👌🕵️, if it still persists you'll have to check if "lodash" supports babel 7.

timneutkens avatar Apr 30 '18 22:04 timneutkens

@timneutkens Thanks for the info. I was browsing the next.js source files minutes ago and discovered that also.

This is what my updated .babelrc looks like

{
	"presets": [
		"next/babel",
	],
	"plugins": [
    	
	],
	"comments": false,
	"compact": true,
}

Stripped down everything but I still get the same error

 ERROR  Failed to compile with 1 errors                                                 12:11:05 AM

 error  in ./pages/_document.js

Module build failed: Error: [BABEL] /Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/pages/_document.js: .value is not a valid Plugin property
    at /Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/config/validation/plugins.js:54:56
    at Array.forEach (<anonymous>)
    at validatePluginObject (/Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/config/validation/plugins.js:52:20)
    at /Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:215:53
    at cachedFunction (/Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/config/caching.js:42:17)
    at loadPluginDescriptor (/Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:207:10)
    at /Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:64:16
    at Array.map (<anonymous>)
    at recurseDescriptors (/Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:63:36)
    at loadFullConfig (/Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/config/full.js:112:6)
    at /Users/ezeugwupaschal/Documents/Gitlab/zyombo/backend/node_modules/@babel/core/lib/transform.js:28:33
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

 @ multi ./pages/_document.js

(node:589) DeprecationWarning: Module.chunks: Use Module.forEachChunk/mapChunks/getNumberOfChunks/isInChunk/addChunk/removeChunk instead
> Ready on http://localhost:3000

paschaldev avatar Apr 30 '18 23:04 paschaldev

This is my _document.js file. Th scss file is processed by webpack config in next.config.js

import Document, { Head, Main, NextScript } from 'next/document'

import 'react-fancy-button/dist/FancyButton.scss'

export default class MyDocument extends Document {

    static async getInitialProps(ctx) {
        const initialProps = await Document.getInitialProps(ctx)
        return { ...initialProps }
    }

    render () {
        return (
            <html>
                <Head>
                    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
                    <link rel='stylesheet' href='/_next/static/vendor.css' />
                    <link rel='stylesheet' href='/_next/static/style.css' />
                    <link href="https://fonts.googleapis.com/css?family=Montserrat:100,300,400,500,700,900" rel="stylesheet" />
                    <link href="https://fonts.googleapis.com/css?family=Quicksand:300,400,500,700" rel="stylesheet"/>
                </Head>
                <body>
                    <Main />
                    <NextScript />
                </body>
            </html>
            )
    }
}

paschaldev avatar Apr 30 '18 23:04 paschaldev

Plugin 0 specified in "/home/travis/build/GabrielDuarteM/portfolio/node_modules/next/babel.js" provided an invalid property of "default" (While processing preset: "/home/travis/build/GabrielDuarteM/portfolio/node_modules/next/babel.js")

Happened to me too, but only when running the tests (using jest).

Reproducible on https://github.com/GabrielDuarteM/portfolio, just run yarn add next to install the latest next version and run yarn test to run the tests.

The complete error log can be seen on this Travis build

yarn start and yarn build is running fine, only yarn test throws that error.

package.json

{
  "name": "portfolio",
  "version": "1.0.0",
  "main": "index.js",
  "author": "Gabriel Duarte <[email protected]> (https://github.com/GabrielDuarteM/)",
  "license": "MIT",
  "scripts": {
    "start": "next src",
    "start:prod": "next start src -p $PORT",
    "prebuild": "rimraf src/out",
    "build": "next build src && yarn export && cp src/root/* src/out",
    "export": "next export src",
    "deploy": "yarn build && netlify deploy",
    "deploy:staging": "yarn deploy -e staging",
    "test": "jest",
    "lint": "yarn eslint src/**/*.js",
    "ci": "yarn build && yarn test && yarn lint"
  },
  "dependencies": {
    "next": "^6.0.0",
    "react": "^16.3.2",
    "react-dom": "^16.3.2"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.3",
    "babel-preset-env": "^1.6.1",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "eslint": "4.19.1",
    "eslint-config-airbnb": "16.1.0",
    "eslint-config-prettier": "^2.9.0",
    "eslint-plugin-import": "2.11.0",
    "eslint-plugin-jsx-a11y": "6.0.3",
    "eslint-plugin-prettier": "^2.6.0",
    "eslint-plugin-react": "7.7.0",
    "jest": "^22.4.3",
    "prettier": "^1.12.1",
    "rimraf": "^2.6.2",
    "sw-precache-webpack-plugin": "^0.11.5"
  }
}

.babelrc

{
  "env": {
    "production": {
      "presets": [
        [
          "env",
          {
            "modules": false,
            "useBuiltIns": true,
            "targets": {
              "browsers": "> 5%"
            }
          }
        ],
        "next/babel"
      ]
    },
    "development": {
      "presets": [
        [
          "env",
          {
            "modules": false,
            "useBuiltIns": true,
            "targets": {
              "browsers": "> 5%"
            }
          }
        ],
        "next/babel"
      ]
    },
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]]
    }
  }
}

next.config.js

const SWPrecacheWebpackPlugin = require("sw-precache-webpack-plugin")

module.exports = {
  exportPathMap: function() {
    return {
      "/": { page: "/" },
      "/about": { page: "/about" },
    }
  },
  excludeFile: str => /\*.{spec,test}.js/.test(str),
  webpack: config => {
    config.plugins.push(
      new SWPrecacheWebpackPlugin({
        verbose: true,
        staticFileGlobsIgnorePatterns: [/\.next\//],
        runtimeCaching: [
          {
            handler: "networkFirst",
            urlPattern: /^https?.*/,
          },
        ],
      }),
    )

    return config
  },
}

GabeDuarteM avatar May 01 '18 02:05 GabeDuarteM

Also experiencing this

 ERROR  Failed to compile with 1 errors                                                                                 

 error  in ./pages/_document.jsx

Module build failed: Error: [BABEL] /Users/luke/development/code/application/web/pages/_document.jsx: .value is not a valid Plugin property

package.json

{
  "name": "application",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start",
    "test": "jest --no-cache",
    "test:debug": "jest --debug",
    "test:verbose": "jest --verbose",
    "test:watch": "jest --watch",
    "test:coverage": "jest -- --coverage --no-cache",
    "test:coverage:view": "jest -- --coverage --no-cache && open coverage/lcov-report/index.html",
    "lint": "eslint .",
    "storybook": "start-storybook -s . -p 6006",
    "build-storybook": "build-storybook",
    "analyze": "export ANALYZE=true && next"
  },
  "dependencies": {
    "classnames": "^2.2.5",
    "es6-promise": "^4.2.4",
    "isomorphic-unfetch": "^2.0.0",
    "js-cookie": "^2.2.0",
    "jsonwebtoken": "^8.2.1",
    "jss": "^9.8.1",
    "material-ui": "^1.0.0-beta.42",
    "moment": "^2.22.1",
    "next": "6.0.0",
    "next-redux-saga": "^2.0.1",
    "next-redux-wrapper": "^1.3.5",
    "prop-types": "^15.6.1",
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "react-iframe": "^1.1.0",
    "react-jss": "^8.4.0",
    "react-popper": "^0.10.1",
    "react-redux": "^5.0.6",
    "redux": "^4.0.0",
    "redux-devtools-extension": "^2.13.2",
    "redux-form": "^7.3.0",
    "redux-saga": "^0.16.0",
    "webpack-bundle-analyzer": "^2.11.1"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0-beta.46",
    "@babel/preset-env": "^7.0.0-beta.46",
    "@storybook/addon-actions": "^3.4.3",
    "@storybook/addon-links": "^3.4.3",
    "@storybook/addon-storyshots": "^3.4.3",
    "@storybook/addons": "^3.4.3",
    "@storybook/react": "^3.4.3",
    "@zeit/next-sass": "^0.1.2",
    "babel-loader": "^8.0.0-beta.2",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "eslint": "^4.19.1",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-plugin-import": "^2.11.0",
    "eslint-plugin-jest": "^21.15.1",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.7.0",
    "jest": "^22.4.3",
    "jest-cli": "^22.4.3",
    "node-sass": "^4.9.0",
    "react-addons-test-utils": "^15.6.2",
    "react-test-renderer": "^16.3.2",
    "webpack": "^3.11.0",
    "webpack-bundle-size-analyzer": "^2.7.0"
  }
}

.babelrc

{
  "presets": [
    "next/babel",
    "@babel/preset-env"
  ]
}

next.config.js

const withSass = require('@zeit/next-sass')

module.exports = withSass({
  cssModules: true,
})

ljanssen5 avatar May 01 '18 02:05 ljanssen5