Skip to content

Commit 34cb05a

Browse files
HaNdTriXtimneutkens
authored andcommittedSep 14, 2018
Remove obsolete webpack plugins (#5158)
Since we are now using webpacks `mode` flag we can get rid of: * `webpack.optimize.ModuleConcatenationPlugin` * `webpack.DefinePlugin` (`process.env.NODE_ENV`) https://webpack.js.org/concepts/mode/
1 parent 1f64082 commit 34cb05a

File tree

7 files changed

+37
-4
lines changed

7 files changed

+37
-4
lines changed
 

‎build/webpack.js

-4
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,10 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, i
267267
// required not to cache removed files
268268
useHashIndex: false
269269
}),
270-
new webpack.DefinePlugin({
271-
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production')
272-
}),
273270
// This is used in client/dev-error-overlay/hot-dev-client.js to replace the dist directory
274271
!isServer && dev && new webpack.DefinePlugin({
275272
'process.env.__NEXT_DIST_DIR': JSON.stringify(distDir)
276273
}),
277-
!dev && new webpack.optimize.ModuleConcatenationPlugin(),
278274
isServer && new PagesManifestPlugin(),
279275
!isServer && new BuildManifestPlugin(),
280276
!isServer && new PagesPlugin(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default () => (
2+
<div id='node-env'>{process.env.NODE_ENV}</div>
3+
)

‎test/integration/basic/test/index.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import hmr from './hmr'
1616
import errorRecovery from './error-recovery'
1717
import dynamic from './dynamic'
1818
import asset from './asset'
19+
import processEnv from './process-env'
1920

2021
const context = {}
2122
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5
@@ -42,6 +43,7 @@ describe('Basic Features', () => {
4243
renderViaHTTP(context.appPort, '/with-cdm'),
4344
renderViaHTTP(context.appPort, '/url-prop'),
4445
renderViaHTTP(context.appPort, '/url-prop-override'),
46+
renderViaHTTP(context.appPort, '/process-env'),
4547

4648
renderViaHTTP(context.appPort, '/nav'),
4749
renderViaHTTP(context.appPort, '/nav/about'),
@@ -71,4 +73,5 @@ describe('Basic Features', () => {
7173
hmr(context, (p, q) => renderViaHTTP(context.appPort, p, q))
7274
errorRecovery(context, (p, q) => renderViaHTTP(context.appPort, p, q))
7375
asset(context)
76+
processEnv(context)
7477
})
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* global describe, it, expect */
2+
import webdriver from 'next-webdriver'
3+
4+
export default (context, render) => {
5+
describe('process.env', () => {
6+
it('should set process.env.NODE_ENV in development', async () => {
7+
const browser = await webdriver(context.appPort, '/process-env')
8+
const nodeEnv = await browser.elementByCss('#node-env').text()
9+
expect(nodeEnv).toBe('development')
10+
browser.close()
11+
})
12+
})
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default () => (
2+
<div id='node-env'>{process.env.NODE_ENV}</div>
3+
)

‎test/integration/production/test/index.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import webdriver from 'next-webdriver'
1515
import fetch from 'node-fetch'
1616
import dynamicImportTests from './dynamic'
17+
import processEnv from './process-env'
1718
import security from './security'
1819
import {BUILD_MANIFEST, REACT_LOADABLE_MANIFEST} from 'next/constants'
1920

@@ -277,5 +278,6 @@ describe('Production Usage', () => {
277278

278279
dynamicImportTests(context, (p, q) => renderViaHTTP(context.appPort, p, q))
279280

281+
processEnv(context)
280282
security(context)
281283
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* global describe, it, expect */
2+
import webdriver from 'next-webdriver'
3+
4+
export default (context) => {
5+
describe('process.env', () => {
6+
it('should set process.env.NODE_ENV in production', async () => {
7+
const browser = await webdriver(context.appPort, '/process-env')
8+
const nodeEnv = await browser.elementByCss('#node-env').text()
9+
expect(nodeEnv).toBe('production')
10+
browser.close()
11+
})
12+
})
13+
}

0 commit comments

Comments
 (0)
Please sign in to comment.