From 34c8c2ad704e4b3172faecb35dca1e544a58da65 Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Fri, 27 Jul 2018 11:08:17 -0400 Subject: [PATCH] fix(build): output aliased cms.js w/ deprecation (#1526) When loading Netlify CMS via script tag from a CDN, the file was named `cms.js` until 2.0, when it was renamed to `netlify-cms.js` in alignment with all packages outputting files that match the package name. To avoid a lot of broken sites and confusion, this commit outputs both filenames and prints a deprecation warning to the console in `cms.js` only. --- .../netlify-cms/scripts/deprecate-old-dist.js | 1 + packages/netlify-cms/webpack.config.js | 29 +++++++++++++++---- website/content/docs/add-to-your-site.md | 8 ++--- website/content/docs/custom-widgets.md | 4 +-- website/content/docs/customization.md | 4 +-- .../content/docs/update-the-cms-version.md | 12 ++++---- website/static/admin/index.html | 6 +--- 7 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 packages/netlify-cms/scripts/deprecate-old-dist.js diff --git a/packages/netlify-cms/scripts/deprecate-old-dist.js b/packages/netlify-cms/scripts/deprecate-old-dist.js new file mode 100644 index 00000000..66da9f5a --- /dev/null +++ b/packages/netlify-cms/scripts/deprecate-old-dist.js @@ -0,0 +1 @@ +console.warn('The `cms.js` file is deprecated and will be removed in the next major release. Please use `netlify-cms.js` instead.'); diff --git a/packages/netlify-cms/webpack.config.js b/packages/netlify-cms/webpack.config.js index 3f5f472c..c19dd54b 100644 --- a/packages/netlify-cms/webpack.config.js +++ b/packages/netlify-cms/webpack.config.js @@ -1,8 +1,27 @@ const path = require('path'); const coreWebpackConfig = require('../netlify-cms-core/webpack.config.js'); -module.exports = { - ...coreWebpackConfig, - context: path.join(__dirname, 'src'), - entry: './index.js', -}; +module.exports = [ + { + ...coreWebpackConfig, + context: path.join(__dirname, 'src'), + entry: './index.js', + }, + + /** + * Output the same script a second time, but named `cms.js`, and with a + * deprecation notice. + */ + { + ...coreWebpackConfig, + context: path.join(__dirname, 'src'), + entry: [ + ...coreWebpackConfig.entry, + path.join(__dirname, 'scripts/deprecate-old-dist.js'), + ], + output: { + ...coreWebpackConfig.output, + filename: 'dist/cms.js', + }, + }, +]; diff --git a/website/content/docs/add-to-your-site.md b/website/content/docs/add-to-your-site.md index 7c3fe161..92619b86 100755 --- a/website/content/docs/add-to-your-site.md +++ b/website/content/docs/add-to-your-site.md @@ -30,7 +30,7 @@ admin └ config.yml ``` -The first file, `admin/index.html`, is the entry point for the Netlify CMS admin interface. This means that users can navigate to `yoursite.com/admin/` to access it. On the code side, it's a basic HTML starter page that loads the necessary CSS and JavaScript files. In this example, we pull those files from a public CDN: +The first file, `admin/index.html`, is the entry point for the Netlify CMS admin interface. This means that users can navigate to `yoursite.com/admin/` to access it. On the code side, it's a basic HTML starter page that loads the Netlify CMS JavaScript file. In this example, we pull the file from a public CDN: ```html @@ -39,14 +39,10 @@ The first file, `admin/index.html`, is the entry point for the Netlify CMS admin Content Manager - - - - - + ``` diff --git a/website/content/docs/custom-widgets.md b/website/content/docs/custom-widgets.md index f636966e..b13ebeea 100644 --- a/website/content/docs/custom-widgets.md +++ b/website/content/docs/custom-widgets.md @@ -45,7 +45,7 @@ CMS.registerWidget(name, control, [preview]); **Example:** ```html - + + + @@ -69,7 +69,7 @@ Registers a template for a collection. **Example:** ```html - + +