Sha256: 5b9a34ab5e0e2ba30c7ed470d210b51d8cd55bd2052de7b04fb6ed46a2eaa11a
Contents?: true
Size: 1.16 KB
Versions: 7
Compression:
Stored size: 1.16 KB
Contents
const ExtractTextPlugin = require('extract-text-webpack-plugin') const path = require('path') const { dev_server: devServer } = require('../config') const postcssConfigPath = path.resolve(process.cwd(), '.postcssrc.yml') const isProduction = process.env.NODE_ENV === 'production' const inDevServer = process.argv.find(v => v.includes('webpack-dev-server')) const isHMR = inDevServer && (devServer && devServer.hmr) const extractCSS = !(isHMR) || isProduction const styleLoader = { loader: 'style-loader', options: { hmr: isHMR, sourceMap: true } } const extractOptions = { fallback: styleLoader, use: [ { loader: 'css-loader', options: { minimize: isProduction, sourceMap: true, importLoaders: 2 } }, { loader: 'postcss-loader', options: { sourceMap: true, config: { path: postcssConfigPath } } } ] } // For production extract styles to a separate bundle const extractCSSLoader = { test: /\.(css)$/i, use: ExtractTextPlugin.extract(extractOptions) } // For hot-reloading use regular loaders const inlineCSSLoader = { test: /\.(css)$/i, use: [styleLoader].concat(extractOptions.use) } module.exports = extractCSS ? extractCSSLoader : inlineCSSLoader
Version data entries
7 entries across 7 versions & 2 rubygems