Git Product home page Git Product logo

nextjs-web-simple's Introduction

一个基于Next.js开发的简单静态网站。

项目依赖:

  • React 版本:16.10
  • typescript 版本:3.6
  • material-ui 版本:4.5

启动命令:

开发模式

yarn dev 或者 npm run dev

生产模式
yarn build
yarn start

或者

npm run build
npm run start
生产模式-导出静态页面

next export 导出所有有可能渲染出的 HTML 内容,适用于静态app。

yarn build
yarn export

或者

npm run build
npm run export

update 2019-10-18

CDN 前缀修饰,请修改 next.config.js 配置。
const isProd = process.env.NODE_ENV === 'production'
module.exports = {
  // You may only need to add assetPrefix in the production.
  assetPrefix: isProd ? 'https://cdn.mydomain.com' : ''
}

Note:Next.js在运行脚本、导出静态文件时会注入前缀,但不会影响 /static 文件夹下的静态资源;

可通过修改 next.config.js 文件中的 publicRuntimeConfigserverRuntimeConfig(仅限Server端)配置,实现 /static 文件夹下的静态资源路径修饰。

// next.config.js
module.exports = {
  serverRuntimeConfig: {
    // Will only be available on the server side
    mySecret: 'secret',
    secondSecret: process.env.SECOND_SECRET, // Pass through env variables
  },
  publicRuntimeConfig: {
    // Will be available on both server and client
    staticFolder: '/static',
  },
}

Thanks!!!

nextjs-web-simple's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.