1
- const { ProvidePlugin } = require ( 'webpack' ) ;
2
- const { ESBuildMinifyPlugin } = require ( 'esbuild-loader' ) ;
1
+ const { ProvidePlugin } = require ( "webpack" ) ;
3
2
4
3
const bsconfig = require ( "./bsconfig.json" ) ;
5
- const path = require ( "path" ) ;
6
4
const remarkSlug = require ( "remark-slug" ) ;
7
- const fs = require ( "fs" ) ;
8
5
9
6
const transpileModules = [ "rescript" ] . concat ( bsconfig [ "bs-dependencies" ] ) ;
10
7
const withTM = require ( "next-transpile-modules" ) ( transpileModules ) ;
@@ -16,54 +13,36 @@ const withMdx = require("./plugins/next-mdx")({
16
13
} ,
17
14
} ) ;
18
15
19
-
20
- // esbuild-loader specific features
21
- // See: https://github.com/privatenumber/esbuild-loader-examples/blob/master/examples/next/next.config.js
22
- function useEsbuildMinify ( config , options ) {
23
- const terserIndex = config . optimization . minimizer . findIndex ( minimizer => ( minimizer . constructor . name === 'TerserPlugin' ) ) ;
24
- if ( terserIndex > - 1 ) {
25
- config . optimization . minimizer . splice (
26
- terserIndex ,
27
- 1 ,
28
- new ESBuildMinifyPlugin ( options ) ,
29
- ) ;
30
- }
31
- }
32
-
33
- const isWebpack5 = true ;
34
16
const config = {
35
- target : "serverless" ,
36
17
pageExtensions : [ "jsx" , "js" , "bs.js" , "mdx" , "mjs" ] ,
37
18
env : {
38
19
ENV : process . env . NODE_ENV ,
39
20
} ,
21
+ swcMinify : true ,
40
22
webpack : ( config , options ) => {
41
23
const { isServer } = options ;
42
- if ( isWebpack5 ) {
43
- if ( ! isServer ) {
44
- // We shim fs for things like the blog slugs component
45
- // where we need fs access in the server-side part
46
- config . resolve . fallback = {
47
- fs : false ,
48
- path : false ,
49
- } ;
50
- }
51
- useEsbuildMinify ( config ) ;
52
- // We need this additional rule to make sure that mjs files are
53
- // correctly detected within our src/ folder
54
- config . module . rules . push ( {
55
- test : / \. m ? j s $ / ,
56
- // v-- currently using an experimental setting with esbuild-loader
57
- //use: options.defaultLoaders.babel,
58
- use : [ { loader : 'esbuild-loader' , options : { loader : 'jsx' } } ] ,
59
- exclude : / n o d e _ m o d u l e s / ,
60
- type : "javascript/auto" ,
61
- resolve : {
62
- fullySpecified : false ,
63
- }
64
- } ) ;
65
- config . plugins . push ( new ProvidePlugin ( { React : "react" } ) ) ;
24
+ if ( ! isServer ) {
25
+ // We shim fs for things like the blog slugs component
26
+ // where we need fs access in the server-side part
27
+ config . resolve . fallback = {
28
+ fs : false ,
29
+ path : false ,
30
+ } ;
66
31
}
32
+ // We need this additional rule to make sure that mjs files are
33
+ // correctly detected within our src/ folder
34
+ config . module . rules . push ( {
35
+ test : / \. m ? j s $ / ,
36
+ // v-- currently using an experimental setting with esbuild-loader
37
+ //use: options.defaultLoaders.babel,
38
+ use : [ { loader : "esbuild-loader" , options : { loader : "jsx" } } ] ,
39
+ exclude : / n o d e _ m o d u l e s / ,
40
+ type : "javascript/auto" ,
41
+ resolve : {
42
+ fullySpecified : false ,
43
+ } ,
44
+ } ) ;
45
+ config . plugins . push ( new ProvidePlugin ( { React : "react" } ) ) ;
67
46
return config ;
68
47
} ,
69
48
async redirects ( ) {
@@ -80,9 +59,6 @@ const config = {
80
59
} ,
81
60
] ;
82
61
} ,
83
- future : {
84
- webpack5 : isWebpack5 ,
85
- } ,
86
62
} ;
87
63
88
64
module . exports = withMdx ( withTM ( config ) ) ;
0 commit comments