Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case `build-html`:
case `develop-html`:
// We don't deal with CSS at all when building the HTML.
// The 'null' loader is used to prevent 'module not found' errors.
// On the other hand CSS modules loaders are necessary.
config.loader(`css`, {
test: /\.css$/,
exclude: /\.module\.css$/,
loader: `null`,
})
// CSS modules
config.loader(`cssModules`, {
test: /\.module\.css$/,
loader: extractTextPlugin(stage).extract(`style`, [
cssModulesConfig(stage),
`postcss`,
]),
})
return config
case `build-javascript`:
// we don't deal with css at all when building the javascript. but
// still need to process the css so offline-plugin knows about the
// various assets referenced in your css.
//
// It's also necessary to process CSS Modules so your JS knows the
// classNames to use.
config.loader(`css`, {
})
)
return isFramework || count > 3
},
}),
// Add a few global variables. Set NODE_ENV to production (enables
// optimizations for React) and whether prefixing links is enabled
// (__PREFIX_PATHS__) and what the link prefix is (__PATH_PREFIX__).
new webpack.DefinePlugin({
"process.env": processEnv(stage, `production`),
__PREFIX_PATHS__: program.prefixPaths,
__PATH_PREFIX__: JSON.stringify(store.getState().config.pathPrefix),
__POLYFILL__: store.getState().config.polyfill,
}),
// Extract CSS so it doesn't get added to JS bundles.
extractTextPlugin(stage),
// Write out mapping between chunk names and their hashed names. We use
// this to add the needed javascript files to each HTML page.
new StatsWriterPlugin(),
// Extract the webpack chunk manifest out of commons.js so commons.js
// doesn't get changed everytime you build. This increases the cache-hit
// rate for commons.js.
new ChunkManifestPlugin({
filename: `chunk-manifest.json`,
manifestVariable: `webpackManifest`,
}),
// Ensure module order stays the same. Supposibly fixed in webpack 2.0.
new webpack.optimize.OccurenceOrderPlugin(),
new GatsbyModulePlugin(),
// new WebpackStableModuleIdAndHash({ seed: 9, hashSize: 47 }),
new HashedChunkIdsPlugin(),
]