Sha256: 6d59add1b28d17f38c8915315c96355d71488602c9e2ce47c72ce925eb36460c

Contents?: true

Size: 858 Bytes

Versions: 29

Compression:

Stored size: 858 Bytes

Contents

/* eslint global-require: 0 */
/* eslint import/no-dynamic-require: 0 */

const { resolve } = require('path')
const { existsSync } = require('fs')
const { merge } = require('webpack-merge')

const getLoaderExtension = (filename) => {
  const matchData = filename.match(/\.([jt]sx?)?(\.erb)?$/)

  if (!matchData) {
    return 'js'
  }

  return matchData[1]
}

const getCustomConfig = () => {
  const path = resolve('config', 'esbuild.config.js')
  if (existsSync(path)) {
    return require(path)
  }
  return {}
}

const getEsbuildLoaderConfig = (filenameToProcess) => {
  const customConfig = getCustomConfig()
  const defaultConfig = {
    loader: require.resolve('esbuild-loader'),
    options: {
      loader: getLoaderExtension(filenameToProcess)
    }
  }

  return merge(defaultConfig, customConfig)
}

module.exports = {
  getEsbuildLoaderConfig
}

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
shakapacker-7.2.3 package/esbuild/index.js
shakapacker-7.3.0.beta.1 package/esbuild/index.js
shakapacker-7.2.2 package/esbuild/index.js
shakapacker-7.2.1 package/esbuild/index.js
shakapacker-7.2.0 package/esbuild/index.js
shakapacker-7.2.0.rc.0 package/esbuild/index.js
shakapacker-7.1.0 package/esbuild/index.js
shakapacker-7.0.3 package/esbuild/index.js
shakapacker-7.0.2 package/esbuild/index.js
shakapacker-7.0.1 package/esbuild/index.js
shakapacker-7.0.0 package/esbuild/index.js
shakapacker-7.0.0.rc.2 package/esbuild/index.js
shakapacker-7.0.0.rc.1 package/esbuild/index.js
shakapacker-7.0.0.rc.0 package/esbuild/index.js
shakapacker-6.6.0 package/esbuild/index.js
shakapacker-6.5.6 package/esbuild/index.js
shakapacker-6.5.5 package/esbuild/index.js
shakapacker-6.5.4 package/esbuild/index.js
shakapacker-6.5.3 package/esbuild/index.js
shakapacker-6.5.2 package/esbuild/index.js