2b41d8a838
* fix(media_folder_relative): use collection name in unpublished entry * refactor: pass arguments as object to AssetProxy ctor * feat: support media folders per collection * feat: resolve media files path based on entry path * fix: asset public path resolving * refactor: introduce typescript for AssetProxy * refactor: code cleanup * refactor(asset-proxy): add tests,switch to typescript,extract arguments * refactor: typescript for editorialWorkflow * refactor: add typescript for media library actions * refactor: fix type error on map set * refactor: move locale selector into reducer * refactor: add typescript for entries actions * refactor: remove duplication between asset store and media lib * feat: load assets from backend using API * refactor(github): add typescript, cache media files * fix: don't load media URL if already loaded * feat: add media folder config to collection * fix: load assets from API when not in UI state * feat: load entry media files when opening media library * fix: editorial workflow draft media files bug fixes * test(unit): fix unit tests * fix: editor control losing focus * style: add eslint object-shorthand rule * test(cypress): re-record mock data * fix: fix non github backends, large media * test: uncomment only in tests * fix(backend-test): add missing displayURL property * test(e2e): add media library tests * test(e2e): enable visual testing * test(e2e): add github backend media library tests * test(e2e): add git-gateway large media tests * chore: post rebase fixes * test: fix tests * test: fix tests * test(cypress): fix tests * docs: add media_folder docs * test(e2e): add media library delete test * test(e2e): try and fix image comparison on CI * ci: reduce test machines from 9 to 8 * test: add reducers and selectors unit tests * test(e2e): disable visual regression testing for now * test: add getAsset unit tests * refactor: use Asset class component instead of hooks * build: don't inline source maps * test: add more media path tests
138 lines
4.1 KiB
JavaScript
138 lines
4.1 KiB
JavaScript
const path = require('path');
|
|
const appVersion = require('./packages/netlify-cms-app/package.json').version;
|
|
const coreVersion = require('./packages/netlify-cms-core/package.json').version;
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
const isTest = process.env.NODE_ENV === 'test';
|
|
const isESM = process.env.NODE_ENV === 'esm';
|
|
|
|
console.log('Build Package:', path.basename(process.cwd()));
|
|
|
|
const defaultPlugins = [
|
|
'lodash',
|
|
[
|
|
'babel-plugin-transform-builtin-extend',
|
|
{
|
|
globals: ['Error'],
|
|
},
|
|
],
|
|
'transform-export-extensions',
|
|
'@babel/plugin-proposal-class-properties',
|
|
'@babel/plugin-proposal-object-rest-spread',
|
|
'@babel/plugin-proposal-export-default-from',
|
|
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
'@babel/plugin-proposal-optional-chaining',
|
|
'@babel/plugin-syntax-dynamic-import',
|
|
'babel-plugin-inline-json-import',
|
|
[
|
|
'module-resolver',
|
|
isESM
|
|
? {
|
|
root: ['./src'],
|
|
alias: {
|
|
coreSrc: './src',
|
|
Actions: './src/actions',
|
|
App: './src/components/App',
|
|
Collection: './src/components/Collection',
|
|
Constants: './src/constants',
|
|
Editor: './src/components/Editor',
|
|
EditorWidgets: './src/components/EditorWidgets',
|
|
Formats: './src/formats',
|
|
Integrations: './src/integrations',
|
|
Lib: './src/lib',
|
|
MediaLibrary: './src/components/MediaLibrary',
|
|
Reducers: './src/reducers',
|
|
Selectors: './src/selectors',
|
|
ReduxStore: './src/redux',
|
|
Routing: './src/routing',
|
|
UI: './src/components/UI',
|
|
Workflow: './src/components/Workflow',
|
|
ValueObjects: './src/valueObjects',
|
|
localforage: 'localforage',
|
|
redux: 'redux',
|
|
},
|
|
extensions: ['.js', '.jsx', '.es', '.es6', '.mjs', '.ts', '.tsx'],
|
|
}
|
|
: {
|
|
root: path.join(__dirname, 'packages/netlify-cms-core/src/components'),
|
|
alias: {
|
|
coreSrc: path.join(__dirname, 'packages/netlify-cms-core/src'),
|
|
Actions: path.join(__dirname, 'packages/netlify-cms-core/src/actions/'),
|
|
Constants: path.join(__dirname, 'packages/netlify-cms-core/src/constants/'),
|
|
Formats: path.join(__dirname, 'packages/netlify-cms-core/src/formats/'),
|
|
Integrations: path.join(__dirname, 'packages/netlify-cms-core/src/integrations/'),
|
|
Lib: path.join(__dirname, 'packages/netlify-cms-core/src/lib/'),
|
|
Reducers: path.join(__dirname, 'packages/netlify-cms-core/src/reducers/'),
|
|
Selectors: path.join(__dirname, 'packages/netlify-cms-core/src/selectors/'),
|
|
ReduxStore: path.join(__dirname, 'packages/netlify-cms-core/src/redux/'),
|
|
Routing: path.join(__dirname, 'packages/netlify-cms-core/src/routing/'),
|
|
ValueObjects: path.join(__dirname, 'packages/netlify-cms-core/src/valueObjects/'),
|
|
localforage: 'localforage',
|
|
redux: 'redux',
|
|
},
|
|
extensions: ['.js', '.jsx', '.es', '.es6', '.mjs', '.ts', '.tsx'],
|
|
},
|
|
],
|
|
];
|
|
|
|
const presets = () => {
|
|
return [
|
|
'@babel/preset-react',
|
|
'@babel/preset-env',
|
|
[
|
|
'@emotion/babel-preset-css-prop',
|
|
{
|
|
autoLabel: true,
|
|
},
|
|
],
|
|
'@babel/typescript',
|
|
];
|
|
};
|
|
|
|
const plugins = () => {
|
|
if (isESM) {
|
|
return [
|
|
...defaultPlugins,
|
|
[
|
|
'transform-define',
|
|
{
|
|
NETLIFY_CMS_APP_VERSION: `${appVersion}`,
|
|
NETLIFY_CMS_CORE_VERSION: `${coreVersion}`,
|
|
},
|
|
],
|
|
[
|
|
'inline-react-svg',
|
|
{
|
|
svgo: {
|
|
plugins: [{ removeViewBox: false }],
|
|
},
|
|
},
|
|
],
|
|
];
|
|
}
|
|
|
|
if (isTest) {
|
|
return [
|
|
...defaultPlugins,
|
|
[
|
|
'inline-react-svg',
|
|
{
|
|
svgo: {
|
|
plugins: [{ removeViewBox: false }],
|
|
},
|
|
},
|
|
],
|
|
];
|
|
}
|
|
|
|
if (!isProduction) {
|
|
return [...defaultPlugins, 'react-hot-loader/babel'];
|
|
}
|
|
|
|
return defaultPlugins;
|
|
};
|
|
|
|
module.exports = {
|
|
presets: presets(),
|
|
plugins: plugins(),
|
|
};
|