Giter VIP home page Giter VIP logo

Comments (3)

resisttheurge avatar resisttheurge commented on May 26, 2024

Thanks for trying out this boilerplate!

There are two important parts to the plugin configuration example you provided, the addtion of 'lodash' to the query.plugins configuration option for the babel loader, and the addition of new LodashModuleReplacementPlugin to the plugins configuration option.

In the boilerplate, the babel loader is configured in the config/rules.js file (due to webpack 2's terminology switch from loaders to rules), but you might notice that there's no query config option. That's because in this boilerplate, the babel configuration is loaded from the .babelrc file at the root of the project.

So, to add the lodash babel plugin to the boilerplate, simply replace the contents of .babelrc with

{
  "plugins": ["lodash"],
  "presets": [
    ["env", {
      "targets": { "node": "current" },
      "modules": false,
      "useBuiltIns": true
    }],
    "stage-0"
  ]
}

The es2015 preset referenced in your example is a subset of the env preset already present in the boilerplate, so it is omitted here.

Webpack plugins are configured in the config/plugins.js file, so you can simply import the lodash replacement plugin there and add it to the plugins array:

'use strict'

const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
const { DefinePlugin } = require('webpack')

const { DEV, PROD, TEST } = require('./env')

const define =
  new DefinePlugin({
    DEV,
    PROD,
    TEST
  })

const lodash = new LodashModuleReplacementPlugin

module.exports = {
  define,
  lodash,
  plugins: [
    define,
    lodash
  ]
}

I hope that helps! If it does, please comment back so I can close the issue. Feel free to ask if anything is unclear.

from babel-webpack-package-boilerplate.

jcheroske avatar jcheroske commented on May 26, 2024

I will make those changes momentarily and let you know how it goes. I'm wondering if you'd be open to the idea of adding the lodash babel and webpack plugins to this boilerplate? They seem really nice and wouldn't introduce a lodash dependency, but if someone did use lodash on their project then the plugins would already be dialed in and would create the smallest build.

I've never done a pull request, and I'm looking for a simple opportunity to try it out and get used to the procedure. If you're into the idea, I'm happy to do the work.

from babel-webpack-package-boilerplate.

resisttheurge avatar resisttheurge commented on May 26, 2024

I'd be fine with adding the lodash babel and webpack plugins, since this is a fairly opinionated boilerplate for the time being, anyway. I probably don't have much more experience with pull requests than you, but I'd be happy to use the opportunity to learn, as well.

I'd say go for it! As you may have noticed, I can't put as much time into this as I'd like to at the moment, so if you'd like to do the same for #3 , have at it as well. I'd like to find a boilerplate CONTRIBUTORS.md before too much happens, but don't let that hold you back for now.

Also, go ahead and make a separate issue for the lodash feature so that it can be associated with the pull request later on. I'm closing this issue for now.

from babel-webpack-package-boilerplate.

Related Issues (3)

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.