-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support Next.js v5 and "config as a function" (#5)
* drop Node 4 from testing * bump patch or minor dev deps * bump tap major * temporarily comment out Next 6 default config prop
- Loading branch information
Showing
8 changed files
with
113 additions
and
7 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
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 |
---|---|---|
|
@@ -4,5 +4,4 @@ node_js: | |
- 'node' | ||
- '8' | ||
- '6' | ||
- '4' | ||
after_success: npm run coverage |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const withPlugins = require('next-compose-plugins') | ||
const images = require('next-images') | ||
const sass = require('@zeit/next-sass') | ||
|
||
// next.js configuration | ||
const nextConfig = { | ||
useFileSystemPublicRoutes: false, | ||
distDir: 'build' | ||
} | ||
|
||
module.exports = withPlugins([ | ||
|
||
// add a plugin with specific configuration | ||
[sass, { | ||
cssModules: true, | ||
cssLoaderOptions: { | ||
localIdentName: '[local]___[hash:base64:5]' | ||
} | ||
}], | ||
|
||
// add a plugin without a configuration | ||
images | ||
|
||
], nextConfig) |
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,20 @@ | ||
{ | ||
"name": "fixture", | ||
"version": "1.0.0", | ||
"description": "Fixture to test against Next.js 5", | ||
"private": true, | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "next build" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@zeit/next-sass": "^0.2.0", | ||
"next": "^5.1.0", | ||
"next-compose-plugins": "^2.1.1", | ||
"next-images": "^0.10.2", | ||
"react": "^16.3.2", | ||
"react-dom": "^16.3.2" | ||
} | ||
} |
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 @@ | ||
export default () => <div>Welcome to next.js!</div> |
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,43 @@ | ||
const path = require('path') | ||
|
||
const tap = require('tap') | ||
const rimraf = require('rimraf') | ||
|
||
const utils = require('./utils') | ||
|
||
const exec = utils.exec | ||
const cli = utils.cli | ||
const readTextFile = utils.readTextFile | ||
const fixturePath = path.resolve(__dirname, 'fixture-next5') | ||
|
||
let npmi = false | ||
tap.beforeEach(() => { | ||
if (npmi) return Promise.resolve() | ||
npmi = true | ||
return exec('npm', 'i', fixturePath) | ||
}) | ||
|
||
tap.afterEach(() => { | ||
return Promise.all(['build'].map(dir => { | ||
return new Promise((resolve, reject) => { | ||
rimraf(path.resolve(fixturePath, dir), err => { | ||
if (err) return reject(err) | ||
resolve() | ||
}) | ||
}) | ||
})) | ||
}) | ||
|
||
tap.test('with next.config.js that exports a function', t => { | ||
return exec('npm', 'run build', fixturePath).then(() => { | ||
return cli('', fixturePath) | ||
}).then(io => { | ||
t.notOk(io.err) | ||
t.notOk(io.stderr) | ||
t.match(io.stdout, /Build ID: 0123456789abcdef0123456789abcdef01234567/) | ||
t.match(io.stdout, /Updated:.*BUILD_ID/) | ||
return readTextFile(path.resolve(fixturePath, 'build', 'BUILD_ID')) | ||
}).then(buildId => { | ||
t.equal(buildId, '0123456789abcdef0123456789abcdef01234567') | ||
}) | ||
}) |