@@ -29,6 +29,14 @@ export default function NetlifyCmsModule(moduleOptions) {
29
29
const configManager = new ConfigManager ( this . options , moduleOptions ) ;
30
30
const config = configManager . config ;
31
31
32
+ const emitNetlifyConfig = compilation => {
33
+ const netlifyConfigYAML = toYAML ( configManager . cmsConfig ) ;
34
+ compilation . assets [ NETLIFY_CONFIG_FILE_NAME ] = {
35
+ source : ( ) => netlifyConfigYAML ,
36
+ size : ( ) => netlifyConfigYAML . length
37
+ } ;
38
+ } ;
39
+
32
40
// This will be called once when builder started
33
41
this . nuxt . hook ( "build:before" , builder => {
34
42
const bundleBuilder = builder . bundleBuilder ;
@@ -42,11 +50,15 @@ export default function NetlifyCmsModule(moduleOptions) {
42
50
webpackConfig . plugins . push ( {
43
51
apply ( compiler ) {
44
52
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
- } ;
53
+ compilation . hooks . additionalAssets . tapAsync (
54
+ "NetlifyCMSPlugin" ,
55
+ callback => {
56
+ emitNetlifyConfig ( compilation ) ;
57
+ callback ( ) ;
58
+ }
59
+ ) ;
60
+
61
+ emitNetlifyConfig ( compilation ) ;
50
62
cb ( ) ;
51
63
} ) ;
52
64
}
0 commit comments