preparable lib, draggable
This commit is contained in:
+32
-4
@@ -28,14 +28,37 @@
|
||||
|
||||
const BuildUtils = {
|
||||
/**
|
||||
* @param {Array} libs
|
||||
* @param {{
|
||||
* src?: string,
|
||||
* dest?: string,
|
||||
* bundle?: boolean,
|
||||
* amdId?: string,
|
||||
* suppressAmd?: boolean,
|
||||
* minify?: boolean,
|
||||
* prepareCommand?: string,
|
||||
* name?: string,
|
||||
* files?: {
|
||||
* src: string,
|
||||
* dest: string,
|
||||
* }[],
|
||||
* }[]} libs
|
||||
* @param {boolean} [skipPreparable]
|
||||
* @return {{src: string, file: string}[]}
|
||||
*/
|
||||
getBundleLibList: function(libs) {
|
||||
getBundleLibList: function(libs, skipPreparable = false) {
|
||||
const list = [];
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {{amdId?: string, src: string}} item
|
||||
* @return {*|string}
|
||||
*/
|
||||
const getFile = item => {
|
||||
if (item.amdId) {
|
||||
if (item.amdId.startsWith('@')) {
|
||||
return item.amdId.slice(1).replace('/', '-') + '.js';
|
||||
}
|
||||
|
||||
return item.amdId + '.js';
|
||||
}
|
||||
|
||||
@@ -44,6 +67,10 @@ const BuildUtils = {
|
||||
|
||||
libs.filter(item => item.bundle)
|
||||
.forEach(item => {
|
||||
if (item.prepareCommand && skipPreparable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.files) {
|
||||
item.files.forEach(item => list.push({
|
||||
src: item.src,
|
||||
@@ -67,8 +94,9 @@ const BuildUtils = {
|
||||
},
|
||||
|
||||
getPreparedBundleLibList: function (libs) {
|
||||
return BuildUtils.getBundleLibList(libs)
|
||||
.map(item => 'client/lib/original/' + item.file);
|
||||
const items = BuildUtils.getBundleLibList(libs);
|
||||
|
||||
return items.map(item => 'client/lib/original/' + item.file);
|
||||
},
|
||||
|
||||
destToOriginalDest: function (dest) {
|
||||
|
||||
@@ -27,9 +27,28 @@
|
||||
************************************************************************/
|
||||
|
||||
const fs = require('fs');
|
||||
const cp = require('child_process');
|
||||
const buildUtils = require('../build-utils');
|
||||
|
||||
// @todo Introduce libs-provider.
|
||||
/**
|
||||
* @type {{
|
||||
* src?: string,
|
||||
* dest?: string,
|
||||
* bundle?: boolean,
|
||||
* amdId?: string,
|
||||
* suppressAmd?: boolean,
|
||||
* minify?: boolean,
|
||||
* prepareCommand?: string,
|
||||
* name?: string,
|
||||
* files?: {
|
||||
* src: string,
|
||||
* dest: string,
|
||||
* }[],
|
||||
* }[]}
|
||||
*/
|
||||
const libs = require('./../../frontend/libs.json');
|
||||
|
||||
const bundleConfig = require('../../frontend/bundle-config.json');
|
||||
|
||||
const libDir = './client/lib';
|
||||
@@ -55,6 +74,11 @@ fs.readdirSync(originalLibDir)
|
||||
fs.readdirSync(originalLibCrmDir)
|
||||
.forEach(file => fs.unlinkSync(originalLibCrmDir + '/' + file));
|
||||
|
||||
libs.filter(it => it.prepareCommand)
|
||||
.forEach(it => {
|
||||
cp.execSync(it.prepareCommand, {stdio: ['ignore', 'ignore', 'pipe']});
|
||||
});
|
||||
|
||||
const stripSourceMappingUrl = path => {
|
||||
/** @var {string} */
|
||||
const originalContents = fs.readFileSync(path, {encoding: 'utf-8'});
|
||||
@@ -94,8 +118,6 @@ const addSuppressAmd = path => {
|
||||
fs.writeFileSync(path, contents, {encoding: 'utf-8'});
|
||||
}
|
||||
|
||||
const bundleLibDataList = buildUtils.getBundleLibList(libs);
|
||||
|
||||
const amdIdMap = {};
|
||||
const suppressAmdMap = {};
|
||||
|
||||
@@ -113,7 +135,7 @@ libs.forEach(item => {
|
||||
amdIdMap[item.src] = 'lib!' + item.amdId;
|
||||
});
|
||||
|
||||
bundleLibDataList.forEach(item => {
|
||||
buildUtils.getBundleLibList(libs, true).forEach(item => {
|
||||
const src = item.src;
|
||||
|
||||
const dest = originalLibDir + '/' + item.file;
|
||||
|
||||
@@ -29,6 +29,22 @@
|
||||
const fs = require('fs');
|
||||
const buildUtils = require('../build-utils');
|
||||
|
||||
/**
|
||||
* @type {{
|
||||
* src?: string,
|
||||
* dest?: string,
|
||||
* bundle?: boolean,
|
||||
* amdId?: string,
|
||||
* suppressAmd?: boolean,
|
||||
* minify?: boolean,
|
||||
* prepareCommand?: string,
|
||||
* name?: string,
|
||||
* files?: {
|
||||
* src: string,
|
||||
* dest: string,
|
||||
* }[],
|
||||
* }[]}
|
||||
*/
|
||||
const libs = require('./../../frontend/libs.json');
|
||||
|
||||
const stripSourceMappingUrl = path => {
|
||||
|
||||
Reference in New Issue
Block a user