我正在将一个Nextjs应用程序部署到Zeit,但是根据它要求添加的文档
module.exports = {
target: 'serverless'
}
与next.config.js中一样
但是我的文件已经包含module.export
const withCSS = require('@zeit/next-css')
module.exports = withCSS({
webpack: function (config) {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]'
},
},
},
)
return config
}
},
)
如何将这些出口合并为一个。请帮帮我!
我尝试做过本期https://github.com/zeit/next-plugins/issues/34和https://github.com/zeit/next-plugins/issues/7的建议
但是withCSS({})
尚无示例答案 0 :(得分:2)
您应该能够像这样组合它们:
const withCSS = require('@zeit/next-css')
module.exports = withCSS({
target: 'serverless',
webpack: function (config) {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]'
},
},
},
)
return config
}
})
答案 1 :(得分:0)
使用这个可爱的插件https://github.com/JerryCauser/next-compose 结合
例如:
const withTS = require('@zeit/next-typescript')
const withSass = require('@zeit/next-sass')
const compose = require('next-compose')
const tsConfig = {/** ts config here */}
const sassConfig = {/** sass config here */}
module.exports = compose([
[withTS, tsConfig],
[withSass, sassConfig],
{
webpack: (config) => {
/**some special code */
return config
}
}
])