Pure webpack way config for webpacker and rails.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes
.gitignore
.prettierignore
.prettierrc
LICENSE
README.md
generate.js
index.js
package.json
webpack.config.dev.js
webpack.config.prod.js
webpack.config.test.js
yarn.lock

README.md

webpacker-pure-config

Pure webpack way config for webpacker and rails.

Providing webpack.config is conpatible with webpacker.rb gem, without any config.

Usage

Default Usage

Simple

module.exports = require('webpacker-pure-config')

Specify env

dev/test/prod env is available.

These append environment specific parameters. (inspired by @rails/webpacker)

If argument is not given, return default config.

const { dev } = require('webpacker-pure-config')
module.exports = dev()

With Options Usage

arg options default value is below.

  • baseDir: string = 'app/javascript/packs'
  • extensions: string[] = ['.js', '.jsx']
  • rules: rule[] = { test: /.jsx?$/, exclude: /node_modules/, use: ['babel-loader'] }

webpack.config.js

const { generate } = require('webpack-pure-config')
module.exports = generate({
  extensions: ['.ts', '.tsx']
  rules: [
    {
      test: /.tsx?$/,
      exclude: /node_modules/,
      use: ['ts-loader']
    }
  ]
})

config/webpack/development.js

const { dev } = require('webpack-pure-config')
const webpackConfig = require('../../webpack.config')
module.exports = dev(webpackConfig)

Custom Usage

webpack.config.js

const { generate } = require('webpack-pure-config')

const baseConfig = generate({
  extensions: ['.ts', '.tsx']
  rules: [
    {
      test: /.tsx?$/,
      exclude: /node_modules/,
      use: ['ts-loader']
    }
  ]
})

module.exports = {
  ...baseConfig,
  plugins: [
    ...baseConfig.plugins,
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
    })
  ]
}

config/webpack/development.js

const { dev } = require('webpack-pure-config')
const webpackConfig = require('../../webpack.config')
module.exports = dev(webpackConfig)

Notes

  • supports Node.js 8.x+

Licence

MIT