mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix(webpack): prefer main
over module
field for server config (#5446)
[release]
This commit is contained in:
parent
1ae433355e
commit
e155ea43d7
@ -147,6 +147,22 @@ export default class WebpackBaseConfig {
|
||||
return optimization
|
||||
}
|
||||
|
||||
resolve() {
|
||||
// Prioritize nested node_modules in webpack search path (#2558)
|
||||
const webpackModulesDir = ['node_modules'].concat(this.buildContext.options.modulesDir)
|
||||
|
||||
return {
|
||||
resolve: {
|
||||
extensions: ['.wasm', '.mjs', '.js', '.json', '.vue', '.jsx', '.ts', '.tsx'],
|
||||
alias: this.alias(),
|
||||
modules: webpackModulesDir
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: webpackModulesDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minimizer() {
|
||||
const minimizer = []
|
||||
const { terser, cache } = this.buildContext.buildOptions
|
||||
@ -414,9 +430,6 @@ export default class WebpackBaseConfig {
|
||||
}
|
||||
|
||||
config() {
|
||||
// Prioritize nested node_modules in webpack search path (#2558)
|
||||
const webpackModulesDir = ['node_modules'].concat(this.buildContext.options.modulesDir)
|
||||
|
||||
const config = {
|
||||
name: this.name,
|
||||
mode: this.mode,
|
||||
@ -427,18 +440,11 @@ export default class WebpackBaseConfig {
|
||||
maxEntrypointSize: 1000 * 1024,
|
||||
hints: this.dev ? false : 'warning'
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.wasm', '.mjs', '.js', '.json', '.vue', '.jsx', '.ts', '.tsx'],
|
||||
alias: this.alias(),
|
||||
modules: webpackModulesDir
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: webpackModulesDir
|
||||
},
|
||||
module: {
|
||||
rules: this.rules()
|
||||
},
|
||||
plugins: this.plugins()
|
||||
plugins: this.plugins(),
|
||||
...this.resolve()
|
||||
}
|
||||
|
||||
// Clone deep avoid leaking config between Client and Server
|
||||
|
@ -53,6 +53,14 @@ export default class WebpackServerConfig extends WebpackBaseConfig {
|
||||
}
|
||||
}
|
||||
|
||||
resolve() {
|
||||
const resolveConfig = super.resolve()
|
||||
|
||||
resolveConfig.resolve.mainFields = ['main', 'module']
|
||||
|
||||
return resolveConfig
|
||||
}
|
||||
|
||||
alias() {
|
||||
const aliases = super.alias()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user