# webpack-profiles

> Profiles support for webpack module bundler

Latest version **1.0.0** (published 2016-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install webpack-profiles
pnpm add webpack-profiles
yarn add webpack-profiles
bun add webpack-profiles
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-04-21 |
| First published | 2016-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Bartosz Schiller |
| Maintainers | barteksch |
| Keywords | webpack, profiles, build, config |

## Links

- npm: https://www.npmjs.com/package/webpack-profiles
- Repository: https://github.com/barteksc/webpack-profiles
- Homepage: https://github.com/barteksc/webpack-profiles#readme
- Issues: https://github.com/barteksc/webpack-profiles/issues
- npm.io page: https://npm.io/package/webpack-profiles

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-04-21

## README

# webpack-profiles
Profiles support for webpack module bundler. It allows you to define multiple configuration profiles in separated file and trigger them e.g. for different build types.

## Installation

`$ npm install webpack-profiles --save-dev`

## Define profiles
Profiles are defined in `profiles.js` file, placed in the root directory of project. Filename can be modified (see [Configuration](#configuration)).

Sample `profiles.js`:

```javascript
var webpack = require('webpack');
module.exports = {
    production: {
        vars: { //section with variables passed to webpack.DefinePlugin
            API_URL: "'http://my.api.com'"
        },
        config: { //section with config merged with main webpack config
            devtool: 'source-map',
            plugins: [
                new webpack.optimize.UglifyJsPlugin()
            ]
        }
    },
    dev: {
        activeByDefault: true, // profile will be triggered if no profiles passed via cmd or options
        vars: {
            API_URL: "'http://localhost:8080'"
        },
        config: {
            devtool: eval
        }
    },
    ...
};
```

## Applying profiles

Profiles are applied by webpack-profiles helper function, i.e. `webpackProfiles(webpackConfigObject, [options])`:

`webpack.config.js`:
```javascript
    
    var webpackProfiles = require('webpack-profiles');

    var config = {
        entry: {
            app: './index.js'
        },
        output: {
            ...
        },
        plugins: [
            ...
        ],
        ...
    };
    
    module.exports = webpackProfiles(config, {profilesFilename: 'name.js'});
```

## Activating profiles
Profiles can be activated in 3 ways:
* passing cmd argument (see [Command line](#command-line))
* providing configuration options (see [Options](#options))
* using `activeByDefault: true` (see [Define profiles](#define-profiles))

## Configuration

### Options
Options can be passed as second argument to webpack-profiles helper function:

```javascript
    defaults: {
        profiles: '', //multiple profiles can be pased as 'profile1,profile2,...'
        profilesFilename: 'profiles.js',
        returnProfiles: false, //see description below
        extend: {
            isDeep: true,
            arrays: 'concat'
        }
    }
```

Webpack configuration is merged using [extendify](https://github.com/bigShai/extendify), additional options can be passed as `extend` (instead of `inPlace`, it's always `true`).

`returnProfiles`: if you set it to `true`, webpack-profiles helper function will return following object:

```javascript
    {
        config: *merged webpack config*,
        profiles: *array with configuration of profiles, that was used in current build*
    }
```

It can be useful when you want to make some custom operations depending on triggered profiles.

### Command line
Some options can be passed as cmd arguments, that way they override values from options object:
* profiles, e.g. `$ webpack --profiles=dev,profile1,profile2`
* profilesFilename, e.g. `$ webpack --profilesFilename=webpack.profiles.js`

Command line argument can be passed in format supported by [yargs](https://github.com/yargs/yargs).

---
_Source: https://npm.io/package/webpack-profiles · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
