next.config.js 中的导出模块
Export Module in next.config.js
请问如何将这两个组合起来并导出
module.exports = withCSS(withImages())
module.exports = {
publicRuntimeConfig: {
API_URL: 'api_url'
},
}
您可以通过将 属性 withCSS
附加到导出的配置对象来将其公开为配置的一部分。
module.exports = {
withCSS: withImages(),
publicRuntimeConfig: {
API_URL: 'api_url'
},
}
只需将它们放在您的最终对象中即可:
module.exports = {
publicRuntimeConfig: {
API_URL: 'api_url'
},
myCSS: withCSS(withImages())
}
您现在只需在导入的变量旁边添加“.myCSS”即可访问第二个元素
如文档所述here。你传递你的插件,然后是配置。
module.exports = withCSS(withImages({
publicRuntimeConfig: {
API_URL: 'api_url'
},
}));
编辑:Example Usage.
您可以使用 next-compose-plugins 库在 config.next.js
文件中添加多个插件:
const withPlugins = require('next-compose-plugins');
const sass = require('@zeit/next-sass');
module.exports = withPlugins([
[sass],
]);
请问如何将这两个组合起来并导出
module.exports = withCSS(withImages())
module.exports = {
publicRuntimeConfig: {
API_URL: 'api_url'
},
}
您可以通过将 属性 withCSS
附加到导出的配置对象来将其公开为配置的一部分。
module.exports = {
withCSS: withImages(),
publicRuntimeConfig: {
API_URL: 'api_url'
},
}
只需将它们放在您的最终对象中即可:
module.exports = {
publicRuntimeConfig: {
API_URL: 'api_url'
},
myCSS: withCSS(withImages())
}
您现在只需在导入的变量旁边添加“.myCSS”即可访问第二个元素
如文档所述here。你传递你的插件,然后是配置。
module.exports = withCSS(withImages({
publicRuntimeConfig: {
API_URL: 'api_url'
},
}));
编辑:Example Usage.
您可以使用 next-compose-plugins 库在 config.next.js
文件中添加多个插件:
const withPlugins = require('next-compose-plugins');
const sass = require('@zeit/next-sass');
module.exports = withPlugins([
[sass],
]);