Updated next config to not need node-sass in production

This commit is contained in:
JJ Kasper
2018-06-02 14:22:34 -05:00
parent 2929827618
commit e72fd02514
19 changed files with 56 additions and 47 deletions

View File

@@ -1,22 +1,26 @@
const withSass = require('@zeit/next-sass')
const { ANALYZE } = process.env
let AnalyzerPlugin
const { ANALYZE, BUILD, NODE_ENV } = process.env
let conf = {
poweredByHeader: false,
}
if (ANALYZE) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
AnalyzerPlugin = BundleAnalyzerPlugin
}
module.exports = withSass({
poweredByHeader: false,
webpack: function(config, { isServer }) {
if (ANALYZE) {
config.plugins.push(
new AnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true,
})
)
}
conf.webpack = function(config, { isServer }) {
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true,
})
)
return config
},
})
}
}
// Only add sass module when building or during dev
if (BUILD || NODE_ENV !== 'production') {
const withSass = require('@zeit/next-sass')
conf = withSass(conf)
}
module.exports = conf