Git Product home page Git Product logo

next-assets-manifest's Introduction

Next Assets Manifest

codecov

Add webpack-assets-manifest to your Next.js project.

npm install next-assets-manifest --save-dev

Requirements

Example Usage

View examples.

assetsManifest, assetsManifestClient, and assetsManifestServer are optional.

The values for these options can be found here.

Add something like this to your next.config.js.

const withAssetsManifest = require('next-assets-manifest');

module.exports = withAssetsManifest({
  // These options are used for both client and server manifest plugins.
  assetsManifest: {
    done(manifest) {
      console.log(`${manifest}`);

      // You can get the options Next.js uses, if you need it for anything.
      console.log(manifest.options.extra.nextOptions);
    },
  },
  // Customize the client side manifest.
  assetsManifestClient: {
    output: 'client-manifest.json',
  },
  // Customize the server side manifest.
  assetsManifestServer: {
    output: 'server-manifest.json',
  },
});

next-assets-manifest's People

Contributors

webdeveric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sambacha

next-assets-manifest's Issues

Build fails for Invalid schema object

The problem

After adding simple assetsMenifest in next.config.js and trying to run npm run build. However, the build fails and does not generate assets-manifest.js.

Technical details

The build is failing with following output in the console.

> Build error occurred
ValidationError: Invalid schema object. WebpackAssetsManifest has been initialized using a schema object that does not match the API schema.
 - schema has an unknown property 'nextOptions'. These properties are valid:
   object { enabled?, assets?, output?, replacer?, space?, writeToDisk?, fileExtRegex?, sortManifest?, merge?, publicPath?, contextRelativeKeys?, apply?, customize?, transform?, done?, entrypoints?, entrypointsKey?, entrypointsUseAssets?, integrity?, integrityHashes?, integrityPropertyName? }
   -> Webpack Assets Manifest options
    at validate (E:\AEM\nextjs-sample-app\node_modules\schema-utils\dist\validate.js:105:11)
    at E:\AEM\nextjs-sample-app\node_modules\next-assets-manifest\node_modules\webpack-assets-manifest\src\WebpackAssetsManifest.js:73:7
    at SyncHook.eval [as call] (eval at create (E:\AEM\nextjs-sample-app\node_modules\next-assets-manifest\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (E:\AEM\nextjs-sample-app\node_modules\next-assets-manifest\node_modules\tapable\lib\Hook.js:154:20)
    at WebpackAssetsManifest.apply (E:\AEM\nextjs-sample-app\node_modules\next-assets-manifest\node_modules\webpack-assets-manifest\src\WebpackAssetsManifest.js:119:29)
    at createCompiler (E:\AEM\nextjs-sample-app\node_modules\next\dist\compiled\webpack\bundle5.js:134206:12)
    at create (E:\AEM\nextjs-sample-app\node_modules\next\dist\compiled\webpack\bundle5.js:134267:16)     
    at webpack (E:\AEM\nextjs-sample-app\node_modules\next\dist\compiled\webpack\bundle5.js:134291:32)    
    at Object.f [as webpack] (E:\AEM\nextjs-sample-app\node_modules\next\dist\compiled\webpack\bundle5.js:89548:16)
    at E:\AEM\nextjs-sample-app\node_modules\next\dist\build\compiler.js:31:40 {
  errors: [
    {
      keyword: 'additionalProperties',
      dataPath: '',
      schemaPath: '#/additionalProperties',
      params: [Object],
      message: 'should NOT have additional properties',
      schema: false,
      parentSchema: [Object],
      data: [Object]
    }
  ],
  schema: {
    title: 'Webpack Assets Manifest options schema',
    description: 'Webpack Assets Manifest options',
    type: 'object',
    additionalProperties: false,
    properties: {
      enabled: [Object],
      assets: [Object],
      output: [Object],
      replacer: [Object],
      space: [Object],
      writeToDisk: [Object],
      fileExtRegex: [Object],
      sortManifest: [Object],
      merge: [Object],
      publicPath: [Object],
      contextRelativeKeys: [Object],
      apply: [Object],
      customize: [Object],
      transform: [Object],
      done: [Object],
      entrypoints: [Object],
      entrypointsKey: [Object],
      entrypointsUseAssets: [Object],
      integrity: [Object],
      integrityHashes: [Object],
      integrityPropertyName: [Object]
    },
    definitions: { functionOrNull: [Object] }
  },
  headerName: 'WebpackAssetsManifest',
  baseDataPath: 'schema',
  postFormatter: null
}
info  - Creating an optimized production build .npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nextjs-sample-app@ build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nextjs-sample-app@ build 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!     C:\Users\<my_user>\AppData\Roaming\npm-cache\_logs\2021-12-16T21_04_34_217Z-debug.log

The next.js app is pretty basic. Trying to rum build just after creating new next.js app using npx create-next-app command.

package.json file dependencies reference

{
  "name": "nextjs-sample-app",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "next": "12.0.7",
    "next-assets-manifest": "^0.2.0",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "webpack-assets-manifest": "^5.0.6",
    "xmldom": "^0.6.0"
  },
  "devDependencies": {
    "eslint": "8.4.1",
    "eslint-config-next": "12.0.7"
  }
}

Next.js version

v12.0.7

Next.js config

next.config.js file

const withAssetsManifest = require("next-assets-manifest");

module.exports = withAssetsManifest({
  assetsManifest: {
    // https://github.com/webdeveric/webpack-assets-manifest#options-read-the-schema
    output: "assets-manifest.json",
  },
});

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.