[英]How to add more than two plugins in a next.config.js
我想在我们公司的项目中实现sass和BEM方法,但是,将sass插件添加到现有代码几乎没有什么麻烦。 目前,我们正在使用打字稿和CSS插件。
const path = require('path')
const withTypescript = require('@zeit/next-typescript')
const withCSS = require('@zeit/next-css')
const withSass = require('@zeit/next-sass');
const configuration = require('./config/configuration.json')
module.exports = withTypescript(
withCSS({
webpack(config) {
if (process.env.ANALYZE) {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true,
}))
}
return config
},
cssModules: true,
serverRuntimeConfig: {
// Will only be available on the server side
},
publicRuntimeConfig: {
// Will be available on both server and client
}
})
)
我想添加sass插件,但在实现sass时仍无法在项目上工作。
这是添加更多插件的方法。
在您的webpack(config) { /* ... */ }
函数中,您可以继续将更多插件推入config.plugins
。
例如,在这里我添加了WebpackBar
插件,该插件可对您的构建脚本进行概要分析。
webpack(config) {
if (process.env.ANALYZE) {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true,
}))
}
config.plugins.push(new WebpackBar({
fancy: true,
profile: true,
basic: false,
}));
// just do as many config.plugins.push() calls as you need
return config
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.