@@ -33,34 +33,32 @@ export default function NetlifyCmsModule(moduleOptions) {
33
33
this . nuxt . hook ( "build:before" , builder => {
34
34
const bundleBuilder = builder . bundleBuilder ;
35
35
36
+ const webpackConfig = getWebpackNetlifyConfig (
37
+ WEBPACK_NETLIFY_COMPILER_NAME ,
38
+ this . options ,
39
+ config
40
+ ) ;
41
+
42
+ webpackConfig . plugins . push ( {
43
+ apply ( compiler ) {
44
+ compiler . hooks . emit . tapAsync ( "NetlifyCMSPlugin" , ( compilation , cb ) => {
45
+ const netlifyConfigYAML = toYAML ( configManager . cmsConfig ) ;
46
+ compilation . assets [ NETLIFY_CONFIG_FILE_NAME ] = {
47
+ source : ( ) => netlifyConfigYAML ,
48
+ size : ( ) => netlifyConfigYAML . length
49
+ } ;
50
+ cb ( ) ;
51
+ } ) ;
52
+ }
53
+ } ) ;
54
+
55
+ const netlifyCompiler = webpack ( webpackConfig ) ;
56
+
36
57
// This will be run just before webpack compiler starts
37
58
this . nuxt . hook ( "build:compile" , ( { name } ) => {
38
59
if ( name !== WEBPACK_CLIENT_COMPILER_NAME ) {
39
60
return ;
40
61
}
41
- const webpackConfig = getWebpackNetlifyConfig (
42
- WEBPACK_NETLIFY_COMPILER_NAME ,
43
- this . options ,
44
- config
45
- ) ;
46
-
47
- webpackConfig . plugins . push ( {
48
- apply ( compiler ) {
49
- compiler . hooks . emit . tapAsync (
50
- "NetlifyCMSPlugin" ,
51
- ( compilation , cb ) => {
52
- const netlifyConfigYAML = toYAML ( configManager . cmsConfig ) ;
53
- compilation . assets [ NETLIFY_CONFIG_FILE_NAME ] = {
54
- source : ( ) => netlifyConfigYAML ,
55
- size : ( ) => netlifyConfigYAML . length
56
- } ;
57
- cb ( ) ;
58
- }
59
- ) ;
60
- }
61
- } ) ;
62
-
63
- const netlifyCompiler = webpack ( webpackConfig ) ;
64
62
65
63
// This will be run just after webpack compiler ends
66
64
netlifyCompiler . hooks . done . tapAsync (
0 commit comments