【问题标题】:nextjs config merging module exportnextjs 配置合并模块导出
【发布时间】:2020-02-14 18:26:31
【问题描述】:

我想要这两个模块导出,谁能告诉我如何合并:

const path = require("path");
const withSass = require('@zeit/next-sass');
const withCSS = require('@zeit/next-css');


module.exports = {
target: "serverless",
webpack(config) {
config.resolve.modules.push(path.resolve("./"));
return config;
}
};

module.exports = withCSS(withSass());

尝试了 stackoverflow 上描述的多种方法,不幸的是我自己的想法没有奏效。第一个模块用于绝对路径,第二个模块用于引导。如果您对如何更轻松地获得结果有一般性建议,我将不胜感激。

【问题讨论】:

标签: javascript next.js


【解决方案1】:

试试这个方法:

const withPlugins = require('next-compose-plugins');
const withCss = require('@zeit/next-css');
const withSass = require('@zeit/next-sass');
const withImages = require('next-images');

const nextConfig = {
    ... // webpack configs if you have
    return config;
  },
};

module.exports = withPlugins(
  [
    [withImages],
    [withCss],
    [
      withSass, // if you have other options go this way
      {
        cssModules: true,
        cssLoaderOptions: {
          localIdentName: '[path]___[local]___[hash:base64:5]',
        },
      },
    ],
  ],
  nextConfig,
);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    • 2021-11-23
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多