|
54 | 54 | "scripts": { |
55 | 55 | "dev":"next", |
56 | 56 | "build":"next build", |
57 | | -"start":"next start", |
58 | | -"export":"NODE_ENV=production npm run build && next export -o docs && touch docs/.nojekyll" |
| 57 | +"start":"next start" |
59 | 58 | } |
60 | 59 | } |
61 | 60 | ``` |
62 | | - (theexport script isfor github pages) |
63 | 61 |
|
64 | 62 | ### [Typescript](https://github.com/zeit/next.js#typescript) |
65 | 63 |
|
|
347 | 345 | assetPrefix: isProd? prodAssetPrefix:'';, |
348 | 346 | }); |
349 | 347 | ``` |
350 | | -2. change`as` propin`next/Link` to add`linkPrefix` |
351 | | -```tsx |
352 | | - import React from'react'; |
353 | | - import Link from'next/link'; |
354 | | - import { join } from'path'; |
355 | | -
|
356 | | - const linkPrefix = process.env.LINK_PREFIX; |
357 | | -
|
358 | | - const PrefixedLink: React.FC<PrefixedLinkProps> = ({ |
359 | | - href, |
360 | | - as = href, |
361 | | - linkPrefix = LINK_PREFIX, |
362 | | - ...props |
363 | | - }) =><Link href={href} as={join(linkPrefix,as.toString())} {...props} />; |
364 | | -
|
365 | | -export default PrefixedLink; |
366 | | -``` |
| 348 | +2. change`as` propin`next/Link` to add`linkPrefix`, similar to`src/features/link/Link.tsx`in the example setup |
367 | 349 | 3. change`scripts`in`package.json` |
368 | 350 | ```json |
369 | 351 | { |
|
381 | 363 | ```sh |
382 | 364 | npm i -D @babel/plugin-proposal-nullish-coalescing-operator @babel/plugin-proposal-optional-chaining |
383 | 365 | ``` |
| 366 | +2. add the plugins to`babel.config.js` |
| 367 | +```js |
| 368 | + module.exports = { |
| 369 | + presets: [ |
| 370 | + // ... |
| 371 | + ], |
| 372 | + plugins: [ |
| 373 | +'@babel/plugin-proposal-optional-chaining', |
| 374 | +'@babel/plugin-proposal-nullish-coalescing-operator', |
| 375 | + ], |
| 376 | + }; |
| 377 | +``` |
384 | 378 |
|
385 | 379 | ### Dotenv |
386 | 380 | 1. |
|