Sha256: d1d6f6f8847c37bb1672426e2caf243af4f75d4a634883835d10bcc6c0c996f2

Contents?: true

Size: 1.95 KB

Versions: 17

Compression:

Stored size: 1.95 KB

Contents

const TerserPlugin = require('terser-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const safePostCssParser = require('postcss-safe-parser')
const Base = require('./base')

module.exports = class extends Base {
  constructor() {
    super()

    this.plugins.append(
      'Compression',
      new CompressionPlugin({
        filename: '[path].gz[query]',
        algorithm: 'gzip',
        cache: true,
        test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
      })
    )

    if ('brotli' in process.versions) {
      this.plugins.append(
        'Compression Brotli',
        new CompressionPlugin({
          filename: '[path].br[query]',
          algorithm: 'brotliCompress',
          cache: true,
          test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
        })
      )
    }

    this.plugins.append(
      'OptimizeCSSAssets',
      new OptimizeCSSAssetsPlugin({
        parser: safePostCssParser,
        map: {
          inline: false,
          annotation: true
        }
      })
    )

    this.config.merge({
      devtool: 'source-map',
      stats: 'normal',
      bail: true,
      optimization: {
        minimizer: [
          new TerserPlugin({
            parallel: true,
            cache: true,
            sourceMap: true,
            terserOptions: {
              parse: {
                // Let terser parse ecma 8 code but always output
                // ES5 compliant code for older browsers
                ecma: 8
              },
              compress: {
                ecma: 5,
                warnings: false,
                comparisons: false
              },
              mangle: {
                safari10: true
              },
              output: {
                ecma: 5,
                comments: false,
                ascii_only: true
              }
            }
          })
        ]
      }
    })
  }
}

Version data entries

17 entries across 17 versions & 5 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/@rails/webpacker/package/environments/production.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/@rails/webpacker/package/environments/production.js
webpacker-4.3.0 package/environments/production.js
enju_library-0.3.8 spec/dummy/node_modules/@rails/webpacker/package/environments/production.js
webpacker-5.1.1 package/environments/production.js
webpacker-5.1.0 package/environments/production.js
webpacker-5.0.1 package/environments/production.js
webpacker-5.0.0 package/environments/production.js
jetpacker-0.4.2 package/environments/production.js
jetpacker-0.4.1 package/environments/production.js
jetpacker-0.4.0 package/environments/production.js
jetpacker-0.3.0 package/environments/production.js
jetpacker-0.2.0 package/environments/production.js
webpacker-4.2.2 package/environments/production.js
webpacker-4.2.1 package/environments/production.js
webpacker-4.2.0 package/environments/production.js
webpacker-4.1.0 package/environments/production.js