Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
const createStylelint = require('./createStylelint');
|
|
const lintSource = require('./lintSource');
|
|
|
|
/** @typedef {import('stylelint').PostcssPluginOptions} PostcssPluginOptions */
|
|
/** @typedef {import('stylelint').Config} StylelintConfig */
|
|
|
|
/**
|
|
* @type {import('postcss').PluginCreator<PostcssPluginOptions>}
|
|
* */
|
|
module.exports = (options = {}) => {
|
|
const [cwd, tailoredOptions] = isConfig(options)
|
|
? [process.cwd(), { config: options }]
|
|
: [options.cwd || process.cwd(), options];
|
|
const stylelint = createStylelint(tailoredOptions);
|
|
|
|
return {
|
|
postcssPlugin: 'stylelint',
|
|
Once(root, { result }) {
|
|
let filePath = root.source && root.source.input.file;
|
|
|
|
if (filePath && !path.isAbsolute(filePath)) {
|
|
filePath = path.join(cwd, filePath);
|
|
}
|
|
|
|
return lintSource(stylelint, {
|
|
filePath,
|
|
existingPostcssResult: result,
|
|
});
|
|
},
|
|
};
|
|
};
|
|
|
|
module.exports.postcss = true;
|
|
|
|
/**
|
|
* @param {PostcssPluginOptions} options
|
|
* @returns {options is StylelintConfig}
|
|
*/
|
|
function isConfig(options) {
|
|
return 'rules' in options;
|
|
}
|