diff --git a/packages/strapi-generate-new/files/config/environments/production/server.json b/packages/strapi-generate-new/files/config/environments/production/server.json index 4e5d9d1b5e..a72d469d48 100644 --- a/packages/strapi-generate-new/files/config/environments/production/server.json +++ b/packages/strapi-generate-new/files/config/environments/production/server.json @@ -1,6 +1,7 @@ { "host": "localhost", "port": "${process.env.PORT || 1337}", + "production": true, "proxy": { "enabled": false }, diff --git a/packages/strapi-generate-new/files/config/environments/staging/server.json b/packages/strapi-generate-new/files/config/environments/staging/server.json index 4e5d9d1b5e..a72d469d48 100644 --- a/packages/strapi-generate-new/files/config/environments/staging/server.json +++ b/packages/strapi-generate-new/files/config/environments/staging/server.json @@ -1,6 +1,7 @@ { "host": "localhost", "port": "${process.env.PORT || 1337}", + "production": true, "proxy": { "enabled": false }, diff --git a/packages/strapi-plugin-graphql/services/Schema.js b/packages/strapi-plugin-graphql/services/Schema.js index d13249e3ed..dc5d28261b 100644 --- a/packages/strapi-plugin-graphql/services/Schema.js +++ b/packages/strapi-plugin-graphql/services/Schema.js @@ -266,8 +266,10 @@ module.exports = { resolvers, }); - // Write schema. - this.writeGenerateSchema(graphql.printSchema(schema)); + if (!strapi.config.currentEnvironment.server.production) { + // Write schema. + this.writeGenerateSchema(graphql.printSchema(schema)); + } // Remove custom scaler (like Upload); typeDefs = Types.removeCustomScalar(typeDefs, resolvers); diff --git a/packages/strapi-plugin-users-permissions/services/UsersPermissions.js b/packages/strapi-plugin-users-permissions/services/UsersPermissions.js index 397fb1221a..6df284bd8e 100644 --- a/packages/strapi-plugin-users-permissions/services/UsersPermissions.js +++ b/packages/strapi-plugin-users-permissions/services/UsersPermissions.js @@ -438,8 +438,10 @@ module.exports = { try { // Disable auto-reload. strapi.reload.isWatching = false; - // Rewrite actions.json file. - fs.writeFileSync(actionsPath, JSON.stringify({ actions: data }), 'utf8'); + if (!strapi.config.currentEnvironment.server.production) { + // Rewrite actions.json file. + fs.writeFileSync(actionsPath, JSON.stringify({ actions: data }), 'utf8'); + } // Set value to AST to avoid restart. _.set(strapi.plugins['users-permissions'], 'config.actions', data); // Disable auto-reload. diff --git a/packages/strapi/lib/core/plugins.js b/packages/strapi/lib/core/plugins.js index 51893e0f8b..a22cf4dfec 100644 --- a/packages/strapi/lib/core/plugins.js +++ b/packages/strapi/lib/core/plugins.js @@ -88,12 +88,18 @@ module.exports = async function() { return; } + const existBuildPath = await fs.pathExists(buildPath); + if (strapi.config.currentEnvironment.server.production && existBuildPath) { + return; + } else if (strapi.config.currentEnvironment.server.production && !existBuildPath) { + console.log('The plugins.json file is missing and the front-end cannot work without it. Please, create it first at development environment.'); + } + // arrange system directories await Promise.all([ fs.remove(sourcePath), (async () => { - const existBuildPath = await fs.pathExists(buildPath); if (existBuildPath) { await fs.remove(buildPath); } else {