npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack2-general-config

v1.2.16

Published

This is a webpack2 configuration for gerneral purpose.

Downloads

22

Readme

Webpack2 configuration Build Status NPM Version

This is the configuration module for webpack2

Contributors

Dependencies

Getting Started

1. Ensure all Dependencies have been resolved.

2. Install application dependencies.

npm install webpack2-general-config

3. Import the module into your webpack configuration file.

const webpack2Config = require('webpack2-genral-config');

4. To use the default settings, initialize the config first. Then there will be 3 different modes of output.

const example = new webpack2Config.Base({
  context: '',
  entry: {},
  outputPath: '',
  publicPath: '',
  alias: {},
  devServerPort: 8100,
  htmlPath: './index.html'
});
  • context: The indicator for the webpack plugins to point where is your source code directory. ex. path.join(__dirname, 'app')
  • entry: The entry points of your project. You can have multiple entry points, please refer to Webpack website ex. {app:['./js/index.js']}
  • outputPath: Your project's output path. ex. path.join(__dirname, 'dist')
  • publicPath: Please refer to publicPath at Webpack website ex. https://github.com/aj120426394/
  • alias: Please refer to resolve.alias at Webpack website ex. {materialize: path.resolve(__dirname, 'app/vendors/materialize/js/bin/materialize.js')}
  • devServerPort: The port number you would like to use for the dev-server. ex. 8100
  • htmlPath: The main HTML file of your project. ex. ./index.html (As we set the context for the webpack, you can use relative path for rest of the setting)

5. After initialized the configuration, you can have the config output with 3 different modes.

const prodConfig = example.buildForProduction(['jquery']);
const devConfig = example.buildForDevelopment();
const devServerConfig = example.buildForDevServer(true);
  • buildForProduction([lib_name]): The configuration for production which include:
    • Remove Package
    • Set NODE_ENV as 'production'
    • Minimize the JS file
    • Chunk output the library (you need to provide the library's name in an array as the parameter)
  • buildForDevelopment(): The configuration for the development which include:
    • inline Sourcemap
  • buildForDevServer(verbose): The configuration for the dev server which include:
    • inline Sourcemap
    • Hot module replacement

6. addStyleConfig(): The initialized configuration does not include bundling .sass .scss .css. But you can use this function to add the style configuration.

Execute this function before execute buildForDevServer(), buildForDevelopment(), buildForProduction()

const cssConfig = {
  filter: '',
  path: [],
  extraResources: [
    path.resolve(__dirname, "node_modules/compass-mixins/lib"),
    path.resolve(__dirname, "app/vendors/materialize/sass")
  ],
  fileName: '',
  prefixWrap: ''
};
example.addStyleConfig(cssConfig)
  • cssConfig:
    • filter (option): This can set the SCSS loader should'include' or 'exclude' the path below during the bundling.
    • path (option): This is the path that you like to include/exclude in the SCSS loader.
    • extraResources (option): The extra resource that you like to include when you are bundling the SCSS.
    • prefixWrap (option): This is the option that can enable postcss-prefixwrap. If you don't want to enable this function, please do not provide it as parameter.
    • fileName (option): The file name of the css file when it be extracted in the production mode. If you leave it blank, it will become the name of your entry point (js).
    • fastLoader (option): Switching from sass-loader to fast-sass-loader. (Enable this will stop supporting the sourcemap and extraResource from sass-loader).

7. addConfig(): Add any additional settings into the configuration.

Execute this function before execute buildForDevServer(), buildForDevelopment(), buildForProduction()

const extraConfig = {
   plugins: [
       new webpack.ProvidePlugin({
           $: 'jquery'
       })
   ]
};
example.addConfig(extraConfig);

Extra

Some other function that can generate the configuration that can be add in addConfig()

  • webpack2-general-config.Style:

    • Style.extractSCSStoCSS({env = 'production', filter = '', path = [], extraResources = [], fileName = '', prefixWrap='', fastLoader = false})
    • Style.inlineSCSStoCSS({env = 'development', filter = '', path=[], extraResources = [], prefixWrap='', fastLoader = false})
    • Style.SCSStoCSSModule({ env = 'development', filter = '', path = [], extraResources = [], sassResource = [], fileName = '', fastLoader = false })
    • Style.addSprite({srcFolder, srcType = '*.png', targetImgFolder, targetSCSSFolder, cssImageRef}):
       Style.addSprite({
          srcFolder: path.resolve(__dirname, 'app/assets/images/icon'),
          srcType: '*.png',
          targetImgFile: path.resolve(__dirname, 'app/assets/images/sprite.png'),
          targetSCSSFile: path.resolve(__dirname, 'app/scss/abstracts/_sprite.scss'),
          cssImageRef: '../asset/images/sprite.png'
         })
  • webpack2-general-config.Util:

    • Util.devServer({ host = 'localhost', port = 8100 })
    • Util.optimize()
    • Util.setEnvironmentVariable(variables)
    • Util.clean (path)
    • Util.providePlugin(provide)
  • webpack2-general-config.Lint:

    • Lint.eslint(path, filter = "exclude")
    • Lint.sassLint(path)