How to use the extract-css-chunks-webpack-plugin function in extract-css-chunks-webpack-plugin

To help you get started, we’ve selected a few extract-css-chunks-webpack-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strues / boldr / packages / tools / src / createWebpackConfig.js View on Github external
exclude: /a\.js|node_modules/,
            // show a warning when there is a circular dependency
            failOnError: false,
          })
        : null,

      _IS_DEV_
        ? new WriteFilePlugin({
            exitOnErrors: false,
            log: true,
            // required not to cache removed files
            useHashIndex: false,
          })
        : null,

      _IS_CLIENT_ ? new ExtractCssChunks() : null,

      _IS_SERVER_ ? new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }) : null,
      _IS_PROD_ ? new webpack.optimize.ModuleConcatenationPlugin() : null,

      // "Use HashedModuleIdsPlugin to generate IDs that preserves over builds."
      // @see: https://github.com/webpack/webpack.js.org/issues/652#issuecomment-273324529
      _IS_PROD_ && _IS_CLIENT_ ? new webpack.HashedModuleIdsPlugin() : null,
      // Extract Webpack bootstrap code with knowledge about chunks into separate cachable package.
      // explicit-webpack-runtime-chunk
      _IS_CLIENT_ && _IS_PROD_
        ? new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            minChunks: module => /node_modules/.test(module.resource),
          })
        : null,
      // Extract Webpack bootstrap code with knowledge about chunks into separate cachable package.
github medfreeman / nuxt-netlify-cms-module / src / webpack.config.js View on Github external
limit: 1000, // 1 KO
            name: "public/fonts/[name].[hash:7].[ext]"
          }
        }
      ]
    },
    resolve: {
      alias: {
        extensions: EXTENSIONS_DIR
      }
    },
    plugins: [
      // CSS extraction)
      ...(nuxtOptions.build.extractCSS
        ? [
            new ExtractCssChunksPlugin(
              Object.assign(
                {
                  filename: CSS_FILENAME,
                  chunkFilename: CSS_FILENAME,
                  // TODO: https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/issues/132
                  reloadAll: true
                },
                nuxtOptions.build.extractCSS
              )
            )
          ]
        : []),
      new HTMLPlugin({
        title: PAGE_TITLE,
        filename: "index.html",
        template: PAGE_TEMPLATE,
github respond-framework / rudy / packages / boilerplate / server / webpack.config.babel.js View on Github external
],
      runtimeChunk: isClient && {
        name: 'bootstrap',
      },
      splitChunks: isClient && {
        chunks: 'initial',
        cacheGroups: {
          vendors: {
            test: /[\\/]node_modules[\\/]/,
            name: 'vendor',
          },
        },
      },
    },
    plugins: [
      isClient && new ExtractCssChunks(),
      isServer &&
        new webpack.optimize.LimitChunkCountPlugin({
          maxChunks: 1,
        }),
      isClient && isDev && new webpack.HotModuleReplacementPlugin(),
      isClient && isProd && new StatsPlugin('stats.json'),
      isClient && isProd && new webpack.HashedModuleIdsPlugin(), // not needed for strategy to work (just good practice)
      new WriteFilePlugin(),
    ].filter(Boolean),
  }
}
github react-static / react-static / src / static / webpack / webpack.config.prod.js View on Github external
let extrackCSSChunks = new ExtractCssChunks({
    filename: '[name].[chunkHash:8].css',
    chunkFilename: '[id].[chunkHash:8].css',
  })

  if (!config.extractCssChunks) {
    splitChunks.cacheGroups = {
      styles: {
        name: 'styles',
        test: /\.css$/,
        chunks: 'all',
        enforce: true,
      },
    }
    extrackCSSChunks = new ExtractCssChunks({
      filename: '[name].[chunkHash:8].css',
    })
  }
  return {
    mode: 'production',
    context: path.resolve(__dirname, '../../../node_modules'),
    entry: path.resolve(ROOT, config.entry),
    output: {
      filename: '[name].[hash:8].js', // dont use chunkhash, its not a chunk
      chunkFilename: 'templates/[name].[chunkHash:8].js',
      path: ASSETS,
      publicPath: process.env.REACT_STATIC_ASSETS_PATH || '/',
    },
    optimization: {
      minimize: true,
      minimizer: [
github react-static / react-static / src / static / webpack / webpack.config.prod.js View on Github external
}
        : {},
      modules: [
        path.resolve(__dirname, '../../../node_modules'),
        'node_modules',
        NODE_MODULES,
        SRC,
        DIST,
      ],
      extensions: ['.js', '.json', '.jsx'],
    },
    plugins: [
      new webpack.EnvironmentPlugin(process.env),
      !isNode &&
        (config.extractCssChunks
          ? new ExtractCssChunks()
          : new ExtractTextPlugin({
            filename: getPath => {
              process.env.extractedCSSpath = getPath('styles.[hash:8].css')
              return process.env.extractedCSSpath
            },
            allChunks: true,
          })),
      new CaseSensitivePathsPlugin(),
      !isNode &&
        new webpack.optimize.CommonsChunkPlugin({
          name: 'bootstrap', // Named bootstrap to support the webpack-flush-chunks plugin
          minChunks: Infinity,
        }),
      isNode &&
        new webpack.optimize.LimitChunkCountPlugin({
          maxChunks: 1,
github react-static / react-static / packages / react-static / src / static / webpack / webpack.config.prod.js View on Github external
let extrackCSSChunks = new ExtractCssChunks({
    filename: '[name].[chunkHash:8].css',
    chunkFilename: '[id].[chunkHash:8].css',
  })

  if (!config.extractCssChunks) {
    splitChunks.cacheGroups = {
      styles: {
        name: 'styles',
        test: /\.css$/,
        chunks: 'all',
        enforce: true,
      },
    }
    extrackCSSChunks = new ExtractCssChunks({
      filename: '[name].[chunkHash:8].css',
    })
  }

  return {
    mode: 'production',
    context: path.resolve(__dirname, '../../../node_modules'),
    entry: config.disableRuntime
      ? config.entry
      : [
          require.resolve('../../bootstrapPlugins'),
          require.resolve('../../bootstrapTemplates'),
          require.resolve('../../bootstrapApp'),
        ],
    output: {
      filename: '[name].[hash:8].js', // dont use chunkhash, its not a chunk
github nuxt / nuxt.js / packages / webpack / src / config / base.js View on Github external
plugins () {
    const plugins = []
    const { nuxt, buildOptions } = this.buildContext

    // Add timefix-plugin before others plugins
    if (this.dev) {
      plugins.push(new TimeFixPlugin())
    }

    // CSS extraction)
    if (buildOptions.extractCSS) {
      plugins.push(new ExtractCssChunksPlugin(Object.assign({
        filename: this.getFileName('css'),
        chunkFilename: this.getFileName('css')
      }, buildOptions.extractCSS)))
    }

    plugins.push(new VueLoader.VueLoaderPlugin())

    plugins.push(...(buildOptions.plugins || []))

    plugins.push(new WarningIgnorePlugin(this.warningIgnoreFilter()))

    // Build progress indicator
    plugins.push(new WebpackBar({
      name: this.name,
      color: this.colors[this.name],
      reporters: [
github react-static / react-static / packages / react-static / src / static / webpack / webpack.config.prod.js View on Github external
name: true,
    cacheGroups: {
      vendors: {
        test: /[\\/]node_modules[\\/]/,
        priority: -10,
        chunks: 'all',
      },
      default: {
        minChunks: 2,
        priority: -20,
        reuseExistingChunk: true,
      },
    },
  }

  let extrackCSSChunks = new ExtractCssChunks({
    filename: '[name].[chunkHash:8].css',
    chunkFilename: '[id].[chunkHash:8].css',
  })

  if (!config.extractCssChunks) {
    splitChunks.cacheGroups = {
      styles: {
        name: 'styles',
        test: /\.css$/,
        chunks: 'all',
        enforce: true,
      },
    }
    extrackCSSChunks = new ExtractCssChunks({
      filename: '[name].[chunkHash:8].css',
    })
github react-static / react-static / archives / old-examples / less-antdesign / static.config.js View on Github external
config.plugins.forEach((plugin, index) => {
        if (plugin instanceof ExtractCSS) {
          config.plugins[index] = new ExtractCSS({
            filename: getPath => {
              process.env.extractedCSSpath = 'styles.css'
              return getPath('styles.css')
            },
          })
        }
      })
    }

extract-css-chunks-webpack-plugin

Extract CSS from chunks into stylesheets + HMR. Supports Webpack 4 + SSR

MIT
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis