diff --git a/gatsby-node.js b/gatsby-node.js index 75a5d4fbaae..975456fdcac 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -397,27 +397,24 @@ const style_lint_options = { lintDirtyModulesOnly: true, } -exports.onCreateWebpackConfig = ({ stage, actions, loaders, getConfig }, { ...options }) => { +exports.onCreateWebpackConfig = ({ actions, loaders, getConfig }, { ...options }) => { const config = getConfig() - if (config.optimization) { - config.optimization.minimizer = [new TerserPlugin()] - } - if (stage === 'build-html' || stage === 'develop-html') { - actions.setWebpackConfig({ - module: { - rules: [ - { - test: /analytics/, - use: loaders.null(), - }, - ], - }, - }) - } + const isProduction = config.mode === 'production' + actions.setWebpackConfig({ + devtool: false, + mode: isProduction ? 'production' : 'development', plugins: [new StylelintPlugin({ ...style_lint_options, ...options })], resolve: { modules: [path.resolve(__dirname, 'src'), 'node_modules'], }, + module: { + rules: [ + { + test: /analytics/, + use: loaders.null(), + }, + ], + }, }) }