{"id":15910547,"url":"https://github.com/caviarjs/next-block","last_synced_at":"2025-04-03T01:22:47.898Z","repository":{"id":143737048,"uuid":"188138936","full_name":"caviarjs/next-block","owner":"caviarjs","description":"The official caviar block for next","archived":false,"fork":false,"pushed_at":"2020-03-31T11:57:43.000Z","size":46,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-17T20:59:02.242Z","etag":null,"topics":["caviar","caviar-block"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/caviarjs.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-23T01:26:04.000Z","updated_at":"2019-10-25T08:24:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc88348d-bf15-4e47-8aba-95b7c5965f74","html_url":"https://github.com/caviarjs/next-block","commit_stats":{"total_commits":71,"total_committers":1,"mean_commits":71.0,"dds":0.0,"last_synced_commit":"7a87e95f6d05f2f43917d9d7ad18ad6af948eca8"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caviarjs%2Fnext-block","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caviarjs%2Fnext-block/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caviarjs%2Fnext-block/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caviarjs%2Fnext-block/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caviarjs","download_url":"https://codeload.github.com/caviarjs/next-block/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246917869,"owners_count":20854714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["caviar","caviar-block"],"created_at":"2024-10-06T15:08:30.396Z","updated_at":"2025-04-03T01:22:47.865Z","avatar_url":"https://github.com/caviarjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/caviarjs/next-block.svg?branch=master)](https://travis-ci.org/caviarjs/next-block)\n[![Coverage](https://codecov.io/gh/caviarjs/next-block/branch/master/graph/badge.svg)](https://codecov.io/gh/caviarjs/next-block)\n\u003c!-- optional appveyor tst\n[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/caviarjs/next-block?branch=master\u0026svg=true)](https://ci.appveyor.com/project/caviarjs/next-block)\n--\u003e\n\u003c!-- optional npm version\n[![NPM version](https://badge.fury.io/js/@caviar/next-block.svg)](http://badge.fury.io/js/@caviar/next-block)\n--\u003e\n\u003c!-- optional npm downloads\n[![npm module downloads per month](http://img.shields.io/npm/dm/@caviar/next-block.svg)](https://www.npmjs.org/package/@caviar/next-block)\n--\u003e\n\u003c!-- optional dependency status\n[![Dependency Status](https://david-dm.org/caviarjs/next-block.svg)](https://david-dm.org/caviarjs/next-block)\n--\u003e\n\n# @caviar/next-block\n\nThe official caviar block for next.\n\n## Install\n\n```sh\n$ npm i @caviar/next-block\n```\n\n## Usage\n\nFor most scenarios, `@caviar/next-block` is used by a caviar mixer and usually should not be used directly.\n\n### Config\n\nIn `[configFile].js`\n\n```js\nconst CSS = require('@zeit/next-css')\n\nmodule.exports = {\n  ...otherAnchors,\n\n  [nextAnchorName] (compose) {\n\n    // The config anchor of next should always returns\n    // a FUNCTION!\n    return compose([\n      CSS\n    ], {\n      distDir: '.next',\n      static: {\n        // Set cache-control for static files as max-age=86400\n        maxAge: 86400\n      }\n    })\n  },\n\n  [nextWebpackAnchorName] (\n    webpackConfig,\n    nextOptions,\n    // The webpack module which `@caviar/next-block` uses\n    // as the 3rd argument\n    webpackModule\n  ) {\n\n    // Only add the DefinePlugin for client side\n    if (nextOptions.isServer) {\n      webpackConfig.plugins.push(\n        new webpackModule.DefinePlugin({\n          ...\n        })\n      )\n    }\n\n    // This method must return an object\n    return webpackConfig\n  }\n}\n```\n\n- **nextAnchorName** `string` the name/key of the config anchor which is defined by the mixer who mixes `@caviar/next-block`\n\n- **nextWebpackAnchorName** `string` the name of the config anchor for next webpack.\n\n### extend(plugins: Array, nextConfigMixins: object): Function\n### extend(nextConfigMixins: object): Function\n\nAs the first and the only argument of the config anchor function, `extend` is actually the `withPlugins` method of [`next-compose-plugins`](https://www.npmjs.com/package/next-compose-plugins). Method `extend` extends the next config of the underlying caviar [layer], and provides the ability to merge the config from the current layer with the support of next build phases (such as `require('next/constants').PHASE_PRODUCTION_BUILD`).\n\n- **plugins** `Array\u003cNextPlugin | [NextPlugin, NextPluginOptions]\u003e` Array of next plugin instances. The first parameter of `withPlugins`\n- **nextConfigMixins?** `Object={}` the extra config to mix into the current next configuration. The second parameter of `withPlugins`\n  - **nextConfigMixins.dir** `string` the next dir relative to the current working directory\n  - **nextConfigMixins.static** `object` the options for [serve-static](https://www.npmjs.com/package/serve-static)\n  - **nextConfigMixins.staticFilePublicPath** `string=/static` the url pathname prefix to route to static files\n\n## Hooks\n\n### ...builtInBlockHooks\n\nSee [Caviar Blocks]\n\n### nextConfig `SyncHook`\n\nTriggered after the next config is generated and before using.\n\nCallback parameters:\n\n- **nextConfig**\n- **caviarOptions**\n\n### webpackConfig\n\nTriggered after webpack config is generated and before using.\n\n- **webpackConfig**\n- **nextOptions**\n- **webpackModule**\n- **caviarOptions**\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaviarjs%2Fnext-block","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaviarjs%2Fnext-block","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaviarjs%2Fnext-block/lists"}