Giter VIP home page Giter VIP logo

webpacker-pure-config's Introduction

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

webpacker-pure-config's People

Contributors

euxn23 avatar saitolume avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.