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.
This commit is contained in:
1
packages/netlify-cms/scripts/deprecate-old-dist.js
Normal file
1
packages/netlify-cms/scripts/deprecate-old-dist.js
Normal file
@ -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.');
|
@ -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',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
Reference in New Issue
Block a user