-
-
Notifications
You must be signed in to change notification settings - Fork 201
/
Copy pathdefine.js
38 lines (33 loc) · 1022 Bytes
/
define.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* This file is part of the Symfony Webpack Encore package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
'use strict';
/**
* @import WebpackConfig from '../WebpackConfig'
*/
const webpack = require('webpack');
const PluginPriorities = require('./plugin-priorities');
const applyOptionsCallback = require('../utils/apply-options-callback');
/**
* @param {Array} plugins
* @param {WebpackConfig} webpackConfig
* @returns {void}
*/
module.exports = function(plugins, webpackConfig) {
const definePluginOptions = {
'process.env.NODE_ENV': webpackConfig.isProduction()
? '"production"'
: '"development"',
};
plugins.push({
plugin: new webpack.DefinePlugin(
applyOptionsCallback(webpackConfig.definePluginOptionsCallback, definePluginOptions)
),
priority: PluginPriorities.DefinePlugin
});
};