本文首发: https://shudong.wang/10608.html
使用 next-compose-plugins
const withPlugins = require('next-compose-plugins');
module.exports = withPlugins(
[
[
stylus,{插件一}
],
[
css,{插件二}
]
],
nextConfig
);
webpack config 配置文件
const { plugins } = require('./build/webpack.common')
const nextConfig = {
distDir: 'dist',
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
config.plugins.push(...plugins)
return config
}
};
webpack.common.js 文件
const { DefinePlugin } = require('webpack');
const INIT_ENV = process.env.INIT_ENV
module.exports.plugins = [
new DefinePlugin({
'process.env': {
INIT_ENV: JSON.stringify(INIT_ENV)
}
})
]