1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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/
This commit is contained in:
Henrik Wenz 2018-09-14 13:45:48 +00:00 committed by Tim Neutkens
parent 1f64082c03
commit 34cb05a860
7 changed files with 37 additions and 4 deletions

View file

@ -267,14 +267,10 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, i
// required not to cache removed files
useHashIndex: false
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production')
}),
// This is used in client/dev-error-overlay/hot-dev-client.js to replace the dist directory
!isServer && dev && new webpack.DefinePlugin({
'process.env.__NEXT_DIST_DIR': JSON.stringify(distDir)
}),
!dev && new webpack.optimize.ModuleConcatenationPlugin(),
isServer && new PagesManifestPlugin(),
!isServer && new BuildManifestPlugin(),
!isServer && new PagesPlugin(),

View file

@ -0,0 +1,3 @@
export default () => (
<div id='node-env'>{process.env.NODE_ENV}</div>
)

View file

@ -16,6 +16,7 @@ import hmr from './hmr'
import errorRecovery from './error-recovery'
import dynamic from './dynamic'
import asset from './asset'
import processEnv from './process-env'
const context = {}
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5
@ -42,6 +43,7 @@ describe('Basic Features', () => {
renderViaHTTP(context.appPort, '/with-cdm'),
renderViaHTTP(context.appPort, '/url-prop'),
renderViaHTTP(context.appPort, '/url-prop-override'),
renderViaHTTP(context.appPort, '/process-env'),
renderViaHTTP(context.appPort, '/nav'),
renderViaHTTP(context.appPort, '/nav/about'),
@ -71,4 +73,5 @@ describe('Basic Features', () => {
hmr(context, (p, q) => renderViaHTTP(context.appPort, p, q))
errorRecovery(context, (p, q) => renderViaHTTP(context.appPort, p, q))
asset(context)
processEnv(context)
})

View file

@ -0,0 +1,13 @@
/* global describe, it, expect */
import webdriver from 'next-webdriver'
export default (context, render) => {
describe('process.env', () => {
it('should set process.env.NODE_ENV in development', async () => {
const browser = await webdriver(context.appPort, '/process-env')
const nodeEnv = await browser.elementByCss('#node-env').text()
expect(nodeEnv).toBe('development')
browser.close()
})
})
}

View file

@ -0,0 +1,3 @@
export default () => (
<div id='node-env'>{process.env.NODE_ENV}</div>
)

View file

@ -14,6 +14,7 @@ import {
import webdriver from 'next-webdriver'
import fetch from 'node-fetch'
import dynamicImportTests from './dynamic'
import processEnv from './process-env'
import security from './security'
import {BUILD_MANIFEST, REACT_LOADABLE_MANIFEST} from 'next/constants'
@ -277,5 +278,6 @@ describe('Production Usage', () => {
dynamicImportTests(context, (p, q) => renderViaHTTP(context.appPort, p, q))
processEnv(context)
security(context)
})

View file

@ -0,0 +1,13 @@
/* global describe, it, expect */
import webdriver from 'next-webdriver'
export default (context) => {
describe('process.env', () => {
it('should set process.env.NODE_ENV in production', async () => {
const browser = await webdriver(context.appPort, '/process-env')
const nodeEnv = await browser.elementByCss('#node-env').text()
expect(nodeEnv).toBe('production')
browser.close()
})
})
}