@@ -5,7 +5,6 @@ import UglifyJSPlugin from 'uglifyjs-webpack-plugin'
55import CaseSensitivePathPlugin from 'case-sensitive-paths-webpack-plugin'
66import WriteFilePlugin from 'write-file-webpack-plugin'
77import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin'
8- import { loadPartialConfig , createConfigItem } from '@babel/core'
98import { getPages } from './webpack/utils'
109import PagesPlugin from './plugins/pages-plugin'
1110import NextJsSsrImportPlugin from './plugins/nextjs-ssr-import'
@@ -14,10 +13,6 @@ import UnlinkFilePlugin from './plugins/unlink-file-plugin'
1413import PagesManifestPlugin from './plugins/pages-manifest-plugin'
1514import BuildManifestPlugin from './plugins/build-manifest-plugin'
1615
17- const presetItem = createConfigItem ( require ( './babel/preset' ) , { type : 'preset' } )
18- const hotLoaderItem = createConfigItem ( require ( 'react-hot-loader/babel' ) , { type : 'plugin' } )
19- const reactJsxSourceItem = createConfigItem ( require ( '@babel/plugin-transform-react-jsx-source' ) , { type : 'plugin' } )
20-
2116const nextDir = path . join ( __dirname , '..' , '..' , '..' )
2217const nextNodeModulesDir = path . join ( nextDir , 'node_modules' )
2318const nextPagesDir = path . join ( nextDir , 'pages' )
@@ -30,37 +25,6 @@ const interpolateNames = new Map(defaultPages.map((p) => {
3025 return [ path . join ( nextPagesDir , p ) , `dist/bundles/pages/${ p } ` ]
3126} ) )
3227
33- function babelConfig ( dir , { isServer, dev} ) {
34- const mainBabelOptions = {
35- cacheDirectory : true ,
36- presets : [ ] ,
37- plugins : [
38- dev && ! isServer && hotLoaderItem ,
39- dev && reactJsxSourceItem
40- ] . filter ( Boolean )
41- }
42-
43- const filename = path . join ( dir , 'filename.js' )
44- const externalBabelConfig = loadPartialConfig ( { babelrc : true , filename } )
45- if ( externalBabelConfig && externalBabelConfig . babelrc ) {
46- // Log it out once
47- if ( ! isServer ) {
48- console . log ( `> Using external babel configuration` )
49- console . log ( `> Location: "${ externalBabelConfig . babelrc } "` )
50- }
51- mainBabelOptions . babelrc = true
52- } else {
53- mainBabelOptions . babelrc = false
54- }
55-
56- // Add our default preset if the no "babelrc" found.
57- if ( ! mainBabelOptions . babelrc ) {
58- mainBabelOptions . presets . push ( presetItem )
59- }
60-
61- return mainBabelOptions
62- }
63-
6428function externalsConfig ( dir , isServer ) {
6529 const externals = [ ]
6630
@@ -96,12 +60,10 @@ function externalsConfig (dir, isServer) {
9660}
9761
9862export default async function getBaseWebpackConfig ( dir , { dev = false , isServer = false , buildId, config} ) {
99- const babelLoaderOptions = babelConfig ( dir , { dev, isServer} )
100-
10163 const defaultLoaders = {
10264 babel : {
103- loader : 'babel-loader' ,
104- options : babelLoaderOptions
65+ loader : 'next- babel-loader' ,
66+ options : { dev , isServer }
10567 }
10668 }
10769
0 commit comments