Skip to content

Commit f93375d

Browse files
authored
Merge pull request #27 from swernerx/patch-1
Moved querying of environment variable
2 parents 1d71e97 + f982db7 commit f93375d

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ var loaderSchema = require('./schema/loader-schema');
1515
var pluginSchema = require('./schema/plugin-schema.json');
1616

1717
var NS = fs.realpathSync(__dirname);
18-
var DEV = process.env.NODE_ENV === 'development';
1918
var nextId = 0;
2019

2120
function ExtractTextPluginCompilation() {
@@ -108,7 +107,7 @@ function ExtractTextPlugin(options) {
108107
} else {
109108
schemaTester(pluginSchema, options);
110109
}
111-
this.filename = options.filename || (DEV ? '[name].css' : '[name].[contenthash].css');
110+
this.filename = options.filename || (process.env.NODE_ENV === 'development' ? '[name].css' : '[name].[contenthash].css');
112111
this.id = options.id != null ? options.id : ++nextId;
113112
this.options = {};
114113
mergeOptions(this.options, options);
@@ -292,7 +291,7 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
292291

293292
// HMR: inject file name into corresponding javascript modules in order to trigger
294293
// appropriate hot module reloading of CSS
295-
if (DEV) {
294+
if (process.env.NODE_ENV === 'development') {
296295
compilation.plugin("before-chunk-assets", function() {
297296
extractedChunks.forEach(function(extractedChunk) {
298297
extractedChunk.modules.forEach(function(module) {

loader.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var SingleEntryPlugin = require("webpack/lib/SingleEntryPlugin");
1313
var LimitChunkCountPlugin = require("webpack/lib/optimize/LimitChunkCountPlugin");
1414

1515
var NS = fs.realpathSync(__dirname);
16-
var DEV = process.env.NODE_ENV === 'development'
1716

1817
module.exports = function(source) {
1918
return source;
@@ -133,7 +132,7 @@ module.exports.pitch = function(request) {
133132
//
134133
// All we need is a date that changes during dev, to trigger a reload since
135134
// hashes generated based on the file contents are what trigger HMR.
136-
if (DEV) {
135+
if (process.env.NODE_ENV === 'development') {
137136
resultSource += `
138137
if (module.hot) {
139138
module.hot.accept();

0 commit comments

Comments
 (0)