Skip to content
Snippets Groups Projects
Commit 68a87639 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Use the rollup resolve plugin for finding package asssets

Instead of hardcoding the paths of the node_modules directory we use the node-resolve
plugin of rollup to find the root of the corresponding JS package and calcucate a path from
there.

Resolving a package requires calling an async function, so we have to use await in the rollup config.
Luckily rollup supports configs wrapped in a promise, so we just have to wrap it in a function which returns
a promise.
parent 1a85271a
No related branches found
No related tags found
No related merge requests found
Pipeline #12331 passed
...@@ -6,71 +6,55 @@ import serve from 'rollup-plugin-serve'; ...@@ -6,71 +6,55 @@ import serve from 'rollup-plugin-serve';
import consts from 'rollup-plugin-consts'; import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete'; import del from 'rollup-plugin-delete';
import json from '@rollup/plugin-json'; import json from '@rollup/plugin-json';
import {getBuildInfo, getPackagePath} from '../../rollup.utils.js';
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local'; const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build); console.log("build: " + build);
function getBuildInfo() { export default (async () => {
const child_process = require('child_process');
const url = require('url');
let remote = child_process.execSync('git config --get remote.origin.url').toString().trim();
let commit = child_process.execSync('git rev-parse --short HEAD').toString().trim();
let parsed = url.parse(remote);
let newPath = parsed.path.slice(0, parsed.path.lastIndexOf('.'));
let newUrl = parsed.protocol + '//' + parsed.host + newPath + '/commit/' + commit;
return { return {
info: commit, input: (build !='test') ? ['src/dbp-app-shell.js', 'src/dbp-activity-example.js'] : glob.sync('test/**/*.js'),
url: newUrl, output: {
time: new Date().toISOString(), dir: 'dist',
env: build entryFileNames: '[name].js',
chunkFileNames: 'shared/[name].[hash].[format].js',
format: 'esm',
sourcemap: true
},
onwarn: function (warning, warn) {
// ignore chai warnings
if (warning.code === 'CIRCULAR_DEPENDENCY') {
return;
}
// keycloak bundled code uses eval
if (warning.code === 'EVAL') {
return;
}
warn(warning);
},
plugins: [
del({
targets: 'dist/*'
}),
consts({
environment: build,
buildinfo: getBuildInfo(build),
}),
resolve(),
commonjs(),
json(),
copy({
targets: [
{src: 'assets/silent-check-sso.html', dest:'dist'},
{src: 'assets/index.html', dest: 'dist'},
{src: 'assets/*.json', dest: 'dist'},
{src: await getPackagePath('dbp-common', 'assets/icons/*.svg'), dest: 'dist/local/dbp-common/icons'},
],
}),
(process.env.ROLLUP_WATCH === 'true') ? serve({
contentBase: 'dist',
historyApiFallback: '/index.html',
host: '127.0.0.1', port: 8002}) : false
]
} }
} })();
\ No newline at end of file
export default {
input: (build !='test') ? ['src/dbp-app-shell.js', 'src/dbp-activity-example.js'] : glob.sync('test/**/*.js'),
output: {
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: 'shared/[name].[hash].[format].js',
format: 'esm',
sourcemap: true
},
onwarn: function (warning, warn) {
// ignore chai warnings
if (warning.code === 'CIRCULAR_DEPENDENCY') {
return;
}
// keycloak bundled code uses eval
if (warning.code === 'EVAL') {
return;
}
warn(warning);
},
plugins: [
del({
targets: 'dist/*'
}),
consts({
environment: build,
buildinfo: getBuildInfo(),
}),
resolve(),
commonjs(),
json(),
copy({
targets: [
{src: 'assets/silent-check-sso.html', dest:'dist'},
{src: 'assets/index.html', dest: 'dist'},
{src: 'assets/*.json', dest: 'dist'},
{src: 'node_modules/dbp-common/assets/icons/*.svg', dest: 'dist/local/dbp-common/icons'},
],
}),
(process.env.ROLLUP_WATCH === 'true') ? serve({
contentBase: 'dist',
historyApiFallback: '/index.html',
host: '127.0.0.1', port: 8002}) : false
]
};
...@@ -7,51 +7,53 @@ import json from '@rollup/plugin-json'; ...@@ -7,51 +7,53 @@ import json from '@rollup/plugin-json';
import serve from 'rollup-plugin-serve'; import serve from 'rollup-plugin-serve';
import consts from 'rollup-plugin-consts'; import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete'; import del from 'rollup-plugin-delete';
import {getPackagePath} from '../../rollup.utils.js';
const pkg = require('./package.json'); const pkg = require('./package.json');
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local'; const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build); console.log("build: " + build);
export default (async () => {
export default { return {
input: (build != 'test') ? ['src/dbp-auth.js', 'src/dbp-auth-demo.js'] : glob.sync('test/**/*.js'), input: (build != 'test') ? ['src/dbp-auth.js', 'src/dbp-auth-demo.js'] : glob.sync('test/**/*.js'),
output: { output: {
dir: 'dist', dir: 'dist',
entryFileNames: '[name].js', entryFileNames: '[name].js',
chunkFileNames: 'shared/[name].[hash].[format].js', chunkFileNames: 'shared/[name].[hash].[format].js',
format: 'esm', format: 'esm',
sourcemap: true sourcemap: true
}, },
onwarn: function (warning, warn) { onwarn: function (warning, warn) {
// keycloak bundled code uses eval // keycloak bundled code uses eval
if (warning.code === 'EVAL') { if (warning.code === 'EVAL') {
return; return;
} }
// ignore chai warnings // ignore chai warnings
if (warning.code === 'CIRCULAR_DEPENDENCY') { if (warning.code === 'CIRCULAR_DEPENDENCY') {
return; return;
} }
warn(warning); warn(warning);
}, },
plugins: [ plugins: [
del({ del({
targets: 'dist/*' targets: 'dist/*'
}), }),
consts({ consts({
environment: build, environment: build,
}), }),
resolve(), resolve(),
commonjs(), commonjs(),
json(), json(),
(build !== 'local' && build !== 'test') ? terser() : false, (build !== 'local' && build !== 'test') ? terser() : false,
copy({ copy({
targets: [ targets: [
{src: 'assets/index.html', dest:'dist'}, {src: 'assets/index.html', dest:'dist'},
{src: 'assets/silent-check-sso.html', dest: 'dist/local/' + pkg.name}, {src: 'assets/silent-check-sso.html', dest: 'dist/local/' + pkg.name},
{src: 'assets/favicon.ico', dest:'dist'}, {src: 'assets/favicon.ico', dest:'dist'},
{src: 'node_modules/dbp-common/assets/icons/*.svg', dest: 'dist/local/dbp-common/icons'}, {src: await getPackagePath('dbp-common', 'assets/icons/*.svg'), dest: 'dist/local/dbp-common/icons'},
] ]
}), }),
(process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false
] ]
}; };
})();
\ No newline at end of file
...@@ -8,70 +8,72 @@ import serve from 'rollup-plugin-serve'; ...@@ -8,70 +8,72 @@ import serve from 'rollup-plugin-serve';
import urlPlugin from "@rollup/plugin-url"; import urlPlugin from "@rollup/plugin-url";
import consts from 'rollup-plugin-consts'; import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete'; import del from 'rollup-plugin-delete';
import {getPackagePath} from '../../rollup.utils.js';
const pkg = require('./package.json'); const pkg = require('./package.json');
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local'; const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build); console.log("build: " + build);
export default { export default (async () => {
input: (build != 'test') ? ['src/dbp-data-table-view.js', 'src/dbp-data-table-view-demo.js'] : glob.sync('test/**/*.js'), return {
output: { input: (build != 'test') ? ['src/dbp-data-table-view.js', 'src/dbp-data-table-view-demo.js'] : glob.sync('test/**/*.js'),
dir: 'dist', output: {
entryFileNames: '[name].js', dir: 'dist',
chunkFileNames: 'shared/[name].[hash].[format].js', entryFileNames: '[name].js',
format: 'esm', chunkFileNames: 'shared/[name].[hash].[format].js',
sourcemap: true format: 'esm',
}, sourcemap: true
onwarn: function (warning, warn) { },
// ignore "suggestions" warning re "use strict" onwarn: function (warning, warn) {
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') { // ignore "suggestions" warning re "use strict"
return; if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
} return;
// ignore chai warnings }
if (warning.code === 'CIRCULAR_DEPENDENCY') { // ignore chai warnings
return; if (warning.code === 'CIRCULAR_DEPENDENCY') {
} return;
// keycloak bundled code uses eval }
if (warning.code === 'EVAL') { // keycloak bundled code uses eval
return; if (warning.code === 'EVAL') {
} return;
warn(warning); }
}, warn(warning);
watch: { },
chokidar: true, watch: {
}, chokidar: true,
plugins: [ },
del({ plugins: [
targets: 'dist/*' del({
}), targets: 'dist/*'
consts({ }),
environment: build, consts({
}), environment: build,
resolve(), }),
commonjs(), resolve(),
json(), commonjs(),
urlPlugin({ json(),
limit: 0, urlPlugin({
emitFiles: true, limit: 0,
fileName: 'shared/[name].[hash][extname]' emitFiles: true,
}), fileName: 'shared/[name].[hash][extname]'
(build !== 'local' && build !== 'test') ? terser() : false, }),
copy({ (build !== 'local' && build !== 'test') ? terser() : false,
targets: [ copy({
{src: 'assets/index.html', dest: 'dist'}, //rename: pkg.name + '.html'}, targets: [
{src: 'assets/*.css', dest: 'dist/local/' + pkg.name}, {src: 'assets/index.html', dest: 'dist'},
{src: 'assets/*.ico', dest: 'dist/local/' + pkg.name}, {src: 'assets/*.css', dest: 'dist/local/' + pkg.name},
{src: 'node_modules/dbp-common/dbp-spinner.js', dest: 'dist/local/' + pkg.name, rename: 'spinner.js'}, {src: 'assets/*.ico', dest: 'dist/local/' + pkg.name},
{src: 'node_modules/dbp-common/assets/icons/*.svg', dest: 'dist/local/dbp-common/icons'}, {src: 'assets/nomodule.js', dest: 'dist/local/' + pkg.name},
{src: 'assets/nomodule.js', dest: 'dist/local/' + pkg.name},
{src: '../../node_modules/datatables.net-dt/css', dest: 'dist/local/dbp-data-table-view'}, {src: await getPackagePath('dbp-common', 'assets/icons/*.svg'), dest: 'dist/local/dbp-common/icons'},
{src: '../../node_modules/datatables.net-dt/images', dest: 'dist/local/dbp-data-table-view'}, {src: await getPackagePath('datatables.net-dt', 'css'), dest: 'dist/local/dbp-data-table-view'},
{src: '../../node_modules/datatables.net-responsive-dt/css', dest: 'dist/local/dbp-data-table-view'}, {src: await getPackagePath('datatables.net-dt', 'images'), dest: 'dist/local/dbp-data-table-view'},
{src: '../../node_modules/datatables.net-buttons-dt/css', dest: 'dist/local/dbp-data-table-view'}, {src: await getPackagePath('datatables.net-responsive-dt', 'css'), dest: 'dist/local/dbp-data-table-view'},
], {src: await getPackagePath('datatables.net-buttons-dt', 'css'), dest: 'dist/local/dbp-data-table-view'},
}), ],
}),
(process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8003}) : false (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8003}) : false
] ]
}; };
})();
\ No newline at end of file
...@@ -7,6 +7,7 @@ import json from '@rollup/plugin-json'; ...@@ -7,6 +7,7 @@ import json from '@rollup/plugin-json';
import serve from 'rollup-plugin-serve'; import serve from 'rollup-plugin-serve';
import consts from 'rollup-plugin-consts'; import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete'; import del from 'rollup-plugin-delete';
import {getPackagePath} from '../../rollup.utils.js';
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local'; const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build); console.log("build: " + build);
...@@ -14,36 +15,38 @@ console.log("build: " + build); ...@@ -14,36 +15,38 @@ console.log("build: " + build);
let nextcloudBaseURL = 'https://cloud.tugraz.at'; let nextcloudBaseURL = 'https://cloud.tugraz.at';
let nextcloudFileURL = nextcloudBaseURL + '/apps/files/?dir='; let nextcloudFileURL = nextcloudBaseURL + '/apps/files/?dir=';
export default { export default (async () => {
input: (build !== 'test') ? ['src/demo.js', 'src/dbp-file-source.js'] : glob.sync('test/**/*.js'), return {
output: { input: (build !== 'test') ? ['src/demo.js', 'src/dbp-file-source.js'] : glob.sync('test/**/*.js'),
dir: 'dist', output: {
entryFileNames: '[name].js', dir: 'dist',
chunkFileNames: 'shared/[name].[hash].[format].js', entryFileNames: '[name].js',
format: 'esm', chunkFileNames: 'shared/[name].[hash].[format].js',
sourcemap: true format: 'esm',
}, sourcemap: true
plugins: [ },
del({ plugins: [
targets: 'dist/*' del({
}), targets: 'dist/*'
consts({ }),
environment: build, consts({
nextcloudBaseURL: nextcloudBaseURL, environment: build,
nextcloudFileURL: nextcloudFileURL, nextcloudBaseURL: nextcloudBaseURL,
}), nextcloudFileURL: nextcloudFileURL,
resolve(), }),
commonjs(), resolve(),
json(), commonjs(),
(build !== 'local' && build !== 'test') ? terser() : false, json(),
copy({ (build !== 'local' && build !== 'test') ? terser() : false,
targets: [ copy({
{src: 'assets/index.html', dest: 'dist'}, targets: [
{src: 'assets/favicon.ico', dest: 'dist'}, {src: 'assets/index.html', dest: 'dist'},
{src: '../../node_modules/material-design-icons-svg/paths/*.json', dest: 'dist/local/dbp-common/icons'}, {src: 'assets/favicon.ico', dest: 'dist'},
{src: '../../node_modules/tabulator-tables/dist/css', dest: 'dist/local/dbp-file-source/tabulator-tables'}, {src: await getPackagePath('dbp-common', 'assets/icons/*.svg'), dest: 'dist/local/dbp-common/icons'},
], {src: await getPackagePath('tabulator-tables', 'dist/css'), dest: 'dist/local/dbp-file-source/tabulator-tables'},
}), ],
(process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false }),
] (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false
}; ]
};
})();
\ No newline at end of file
...@@ -8,49 +8,52 @@ import serve from 'rollup-plugin-serve'; ...@@ -8,49 +8,52 @@ import serve from 'rollup-plugin-serve';
import url from "@rollup/plugin-url"; import url from "@rollup/plugin-url";
import consts from 'rollup-plugin-consts'; import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete'; import del from 'rollup-plugin-delete';
import {getPackagePath} from '../../rollup.utils.js';
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local'; const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build); console.log("build: " + build);
export default { export default (async () => {
input: (build != 'test') ? ['src/dbp-knowledge-base-web-page-element-view.js', 'src/dbp-knowledge-base-web-page-element-view-demo.js'] : glob.sync('test/**/*.js'), return {
output: { input: (build != 'test') ? ['src/dbp-knowledge-base-web-page-element-view.js', 'src/dbp-knowledge-base-web-page-element-view-demo.js'] : glob.sync('test/**/*.js'),
dir: 'dist', output: {
entryFileNames: '[name].js', dir: 'dist',
chunkFileNames: 'shared/[name].[hash].[format].js', entryFileNames: '[name].js',
format: 'esm', chunkFileNames: 'shared/[name].[hash].[format].js',
sourcemap: true format: 'esm',
}, sourcemap: true
onwarn: function (warning, warn) { },
// keycloak bundled code uses eval onwarn: function (warning, warn) {
if (warning.code === 'EVAL') { // keycloak bundled code uses eval
return; if (warning.code === 'EVAL') {
} return;
warn(warning); }
}, warn(warning);
plugins: [ },
del({ plugins: [
targets: 'dist/*' del({
}), targets: 'dist/*'
consts({ }),
environment: build, consts({
}), environment: build,
resolve(), }),
commonjs(), resolve(),
json(), commonjs(),
url({ json(),
limit: 0, url({
emitFiles: true, limit: 0,
fileName: 'shared/[name].[hash][extname]' emitFiles: true,
}), fileName: 'shared/[name].[hash][extname]'
(build !== 'local' && build !== 'test') ? terser() : false, }),
copy({ (build !== 'local' && build !== 'test') ? terser() : false,
targets: [ copy({
{src: 'assets/index.html', dest: 'dist'}, targets: [
{src: 'assets/favicon.ico', dest: 'dist'}, {src: 'assets/index.html', dest: 'dist'},
{src: 'node_modules/dbp-common/assets/icons/*.svg', dest: 'dist/local/dbp-common/icons'}, {src: 'assets/favicon.ico', dest: 'dist'},
], {src: await getPackagePath('dbp-common', 'assets/icons/*.svg'), dest: 'dist/local/dbp-common/icons'},
}), ],
(process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false }),
] (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false
}; ]
};
})();
\ No newline at end of file
...@@ -9,51 +9,54 @@ import serve from 'rollup-plugin-serve'; ...@@ -9,51 +9,54 @@ import serve from 'rollup-plugin-serve';
import url from "@rollup/plugin-url" import url from "@rollup/plugin-url"
import consts from 'rollup-plugin-consts'; import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete'; import del from 'rollup-plugin-delete';
import {getPackagePath} from '../../rollup.utils.js';
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local'; const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build); console.log("build: " + build);
export default { export default (async () => {
input: (build != 'test') ? ['src/dbp-person-profile.js', 'src/dbp-person-profile-demo.js'] : glob.sync('test/**/*.js'), return {
output: { input: (build != 'test') ? ['src/dbp-person-profile.js', 'src/dbp-person-profile-demo.js'] : glob.sync('test/**/*.js'),
dir: 'dist', output: {
entryFileNames: '[name].js', dir: 'dist',
chunkFileNames: 'shared/[name].[hash].[format].js', entryFileNames: '[name].js',
format: 'esm', chunkFileNames: 'shared/[name].[hash].[format].js',
sourcemap: true format: 'esm',
}, sourcemap: true
onwarn: function (warning, warn) { },
// keycloak bundled code uses eval onwarn: function (warning, warn) {
if (warning.code === 'EVAL') { // keycloak bundled code uses eval
return; if (warning.code === 'EVAL') {
} return;
warn(warning); }
}, warn(warning);
plugins: [ },
del({ plugins: [
targets: 'dist/*' del({
}), targets: 'dist/*'
consts({ }),
environment: build, consts({
}), environment: build,
resolve(), }),
commonjs(), resolve(),
url({ commonjs(),
limit: 0, url({
include: [ limit: 0,
"../../**/node_modules/select2/**/*.css", include: [
], await getPackagePath('select2', '**/*.css'),
emitFiles: true, ],
fileName: 'shared/[name].[hash][extname]' emitFiles: true,
}), fileName: 'shared/[name].[hash][extname]'
json(), }),
(build !== 'local' && build !== 'test') ? terser() : false, json(),
copy({ (build !== 'local' && build !== 'test') ? terser() : false,
targets: [ copy({
{src: 'assets/index.html', dest: 'dist'}, targets: [
{src: 'node_modules/dbp-common/assets/icons/*.svg', dest: 'dist/local/dbp-common/icons'}, {src: 'assets/index.html', dest: 'dist'},
], {src: await getPackagePath('dbp-common', 'assets/icons/*.svg'), dest: 'dist/local/dbp-common/icons'},
}), ],
(process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false }),
] (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false
}; ]
};
})();
\ No newline at end of file
...@@ -8,51 +8,54 @@ import serve from 'rollup-plugin-serve'; ...@@ -8,51 +8,54 @@ import serve from 'rollup-plugin-serve';
import url from "@rollup/plugin-url" import url from "@rollup/plugin-url"
import consts from 'rollup-plugin-consts'; import consts from 'rollup-plugin-consts';
import del from 'rollup-plugin-delete'; import del from 'rollup-plugin-delete';
import {getPackagePath} from '../../rollup.utils.js';
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local'; const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
console.log("build: " + build); console.log("build: " + build);
export default { export default (async () => {
input: (build != 'test') ? ['src/dbp-person-select.js', 'src/dbp-person-select-demo.js'] : glob.sync('test/**/*.js'), return {
output: { input: (build != 'test') ? ['src/dbp-person-select.js', 'src/dbp-person-select-demo.js'] : glob.sync('test/**/*.js'),
dir: 'dist', output: {
entryFileNames: '[name].js', dir: 'dist',
chunkFileNames: 'shared/[name].[hash].[format].js', entryFileNames: '[name].js',
format: 'esm', chunkFileNames: 'shared/[name].[hash].[format].js',
sourcemap: true format: 'esm',
}, sourcemap: true
onwarn: function (warning, warn) { },
// keycloak bundled code uses eval onwarn: function (warning, warn) {
if (warning.code === 'EVAL') { // keycloak bundled code uses eval
return; if (warning.code === 'EVAL') {
} return;
warn(warning); }
}, warn(warning);
plugins: [ },
del({ plugins: [
targets: 'dist/*' del({
}), targets: 'dist/*'
consts({ }),
environment: build, consts({
}), environment: build,
resolve(), }),
commonjs(), resolve(),
url({ commonjs(),
limit: 0, url({
include: [ limit: 0,
"../../**/node_modules/select2/**/*.css", include: [
], await getPackagePath('select2', '**/*.css'),
emitFiles: true, ],
fileName: 'shared/[name].[hash][extname]' emitFiles: true,
}), fileName: 'shared/[name].[hash][extname]'
json(), }),
(build !== 'local' && build !== 'test') ? terser() : false, json(),
copy({ (build !== 'local' && build !== 'test') ? terser() : false,
targets: [ copy({
{src: 'assets/index.html', dest: 'dist'}, targets: [
{src: 'node_modules/dbp-common/assets/icons/*.svg', dest: 'dist/local/dbp-common/icons'}, {src: 'assets/index.html', dest: 'dist'},
], {src: await getPackagePath('dbp-common', 'assets/icons/*.svg'), dest: 'dist/local/dbp-common/icons'},
}), ],
(process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false }),
] (process.env.ROLLUP_WATCH === 'true') ? serve({contentBase: 'dist', host: '127.0.0.1', port: 8002}) : false
}; ]
};
})();
\ No newline at end of file
import path from 'path';
import url from 'url';
import child_process from 'child_process';
import resolve from '@rollup/plugin-node-resolve';
export function getBuildInfo(build) {
let remote = child_process.execSync('git config --get remote.origin.url').toString().trim();
let commit = child_process.execSync('git rev-parse --short HEAD').toString().trim();
let parsed = url.parse(remote);
let newPath = parsed.path.slice(0, parsed.path.lastIndexOf('.'));
let newUrl = parsed.protocol + '//' + parsed.host + newPath + '/commit/' + commit;
return {
info: commit,
url: newUrl,
time: new Date().toISOString(),
env: build
}
}
export async function getPackagePath(packageName, assetPath) {
const r = resolve();
const id = (await r.resolveId(packageName)).id;
const packageInfo = r.getPackageInfoForId(id);
const fullAssetPath = path.join(packageInfo.root, assetPath);
return path.relative(process.cwd(), fullAssetPath);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment