且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

下一个JS配置多个插件配置

更新时间:2021-09-11 16:50:53

next-compose-plugins 插件提供了更简洁的API,用于为next.js启用和配置插件.

next-compose-plugins plugin provides a cleaner API for enabling and configuring plugins for next.js.

安装 npm install-保存next-compose-plugins

next.config.js 中使用它:

// next.config.js
const withPlugins = require('next-compose-plugins');
const images = require('next-images');
const sass = require('@zeit/next-sass');
const typescript = require('@zeit/next-typescript');

// optional 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,

  // another plugin with a configuration
  [typescript, {
    typescriptLoaderOptions: {
      transpileOnly: false,
    },
  }],

], nextConfig);