Reactify the Tag Selector
This commit is contained in:
parent
506ed313da
commit
897e74c7f1
33 changed files with 1396 additions and 1597 deletions
|
@ -12,7 +12,7 @@ const cluster = require('cluster');
|
|||
async function babelWorker(ev) {
|
||||
const t1 = Date.now();
|
||||
const sourcefile = ev.file;
|
||||
const outfile = path.join('build', sourcefile);
|
||||
const outfile = path.join('build', sourcefile.replace('.jsx', '.js'));
|
||||
const postError = (error) => {
|
||||
process.send({
|
||||
sourcefile,
|
||||
|
@ -28,7 +28,8 @@ async function babelWorker(ev) {
|
|||
let contents = await fs.readFile(sourcefile, 'utf8');
|
||||
if (sourcefile === 'resource/react-dom.js') {
|
||||
// patch react
|
||||
transformed = contents.replace(/ownerDocument\.createElement\((.*?)\)/gi, 'ownerDocument.createElementNS(DOMNamespaces.html, $1)');
|
||||
transformed = contents.replace(/ownerDocument\.createElement\((.*?)\)/gi, 'ownerDocument.createElementNS(DOMNamespaces.html, $1)')
|
||||
.replace("isInputEventSupported = false", 'isInputEventSupported = true');
|
||||
} else if ('ignore' in options && options.ignore.some(ignoreGlob => multimatch(sourcefile, ignoreGlob).length)) {
|
||||
transformed = contents;
|
||||
isSkipped = true;
|
||||
|
|
|
@ -6,7 +6,7 @@ const getJS = require('./js');
|
|||
const getSass = require('./sass');
|
||||
const getSymlinks = require('./symlinks');
|
||||
const { formatDirsForMatcher, getSignatures, writeSignatures, cleanUp, onSuccess, onError} = require('./utils');
|
||||
const { dirs, symlinkDirs, copyDirs, symlinkFiles, jsFiles, ignoreMask } = require('./config');
|
||||
const { dirs, symlinkDirs, copyDirs, symlinkFiles, jsFiles, scssFiles, ignoreMask } = require('./config');
|
||||
|
||||
if (require.main === module) {
|
||||
(async () => {
|
||||
|
@ -23,7 +23,7 @@ if (require.main === module) {
|
|||
getBrowserify(signatures),
|
||||
getCopy(copyDirs.map(d => `${d}/**`), { ignore: ignoreMask }, signatures),
|
||||
getJS(jsFiles, { ignore: ignoreMask }, signatures),
|
||||
getSass('scss/*.scss', { root: 'scss', ignore: ignoreMask }, signatures),
|
||||
getSass(scssFiles, { ignore: ignoreMask }, signatures),
|
||||
getSymlinks(symlinks, { nodir: true, ignore: ignoreMask }, signatures),
|
||||
getSymlinks(symlinkDirs, { ignore: ignoreMask }, signatures),
|
||||
cleanUp(signatures)
|
||||
|
|
|
@ -49,13 +49,20 @@ const browserifyConfigs = [
|
|||
];
|
||||
|
||||
// exclude mask used for js, copy, symlink and sass tasks
|
||||
const ignoreMask = ['**/#*'];
|
||||
const ignoreMask = ['**/#*', '**/_*.scss'];
|
||||
|
||||
const jsFiles = [
|
||||
`{${dirs.join(',')}}/**/*.js`,
|
||||
`!{${symlinkDirs.concat(copyDirs).join(',')}}/**/*.js`
|
||||
`{${dirs.join(',')}}/**/*.jsx`,
|
||||
`!{${symlinkDirs.concat(copyDirs).join(',')}}/**/*.js`,
|
||||
`!{${symlinkDirs.concat(copyDirs).join(',')}}/**/*.jsx`
|
||||
];
|
||||
|
||||
const scssFiles = [
|
||||
'scss/**/*.scss',
|
||||
'chrome/skin/default/zotero/**/*.scss'
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
dirs, symlinkDirs, copyDirs, symlinkFiles, browserifyConfigs, jsFiles, ignoreMask
|
||||
dirs, symlinkDirs, copyDirs, symlinkFiles, browserifyConfigs, jsFiles, scssFiles, ignoreMask
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ const sassRender = universalify.fromCallback(sass.render);
|
|||
|
||||
const ROOT = path.resolve(__dirname, '..');
|
||||
|
||||
async function getSass(source, options, signatures) {
|
||||
async function getSass(source, options, signatures={}) {
|
||||
const t1 = Date.now();
|
||||
const files = await globby(source, Object.assign({ cwd: ROOT }, options ));
|
||||
const totalCount = files.length;
|
||||
|
@ -20,7 +20,9 @@ async function getSass(source, options, signatures) {
|
|||
|
||||
while ((f = files.pop()) != null) {
|
||||
let newFileSignature = await getFileSignature(f);
|
||||
const dest = path.join.apply(this, ['build', 'chrome', 'skin', 'default', 'zotero', 'components', getPathRelativeTo(f, 'scss')]);
|
||||
let destFile = getPathRelativeTo(f, 'scss');
|
||||
destFile = path.join(path.dirname(destFile), path.basename(destFile, '.scss') + '.css');
|
||||
const dest = path.join.apply(this, ['build', 'chrome', 'skin', 'default', 'zotero', destFile]);
|
||||
|
||||
if (f in signatures) {
|
||||
if (compareSignatures(newFileSignature, signatures[f])) {
|
||||
|
@ -34,10 +36,14 @@ async function getSass(source, options, signatures) {
|
|||
}
|
||||
try {
|
||||
const sass = await sassRender({
|
||||
file: f
|
||||
file: f,
|
||||
outFile: dest,
|
||||
sourceMap: true,
|
||||
outputStyle: 'compressed'
|
||||
});
|
||||
|
||||
await fs.outputFile(dest, sass);
|
||||
await fs.outputFile(dest, sass.css);
|
||||
await fs.outputFile(`${dest}.map`, sass.map);
|
||||
onProgress(f, dest, 'sass');
|
||||
signatures[f] = newFileSignature;
|
||||
count++;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const path = require('path');
|
||||
const chokidar = require('chokidar');
|
||||
const multimatch = require('multimatch');
|
||||
const { dirs, jsFiles, ignoreMask, copyDirs, symlinkFiles } = require('./config');
|
||||
const { dirs, jsFiles, scssFiles, ignoreMask, copyDirs, symlinkFiles } = require('./config');
|
||||
const { onSuccess, onError, getSignatures, writeSignatures, cleanUp, formatDirsForMatcher } = require('./utils');
|
||||
const getJS = require('./js');
|
||||
const getSass = require('./sass');
|
||||
|
@ -49,8 +49,12 @@ function getWatch() {
|
|||
try {
|
||||
if (multimatch(path, jsFiles).length && !multimatch(path, ignoreMask).length) {
|
||||
onSuccess(await getJS(path, { ignore: ignoreMask }, signatures));
|
||||
} else if (multimatch(path, 'scss/*.scss').length) {
|
||||
onSuccess(await getSass(path, {}, signatures));
|
||||
} else if (multimatch(path, scssFiles).length) {
|
||||
if (multimatch(path, '**/_*.scss').length) {
|
||||
onSuccess(await getSass(scssFiles, { ignore: ignoreMask }));
|
||||
} else {
|
||||
onSuccess(await getSass(path, {}, signatures));
|
||||
}
|
||||
} else if (multimatch(path, copyDirs.map(d => `${d}/**`)).length) {
|
||||
onSuccess(await getCopy(path, {}, signatures));
|
||||
} else if (multimatch(path, symlinks).length) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue