mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-18 23:42:17 +00:00
add rollup README with useful commands, add alternative rollup config to build one bundle per app without shared chunks, add package-lock.json to repo
This commit is contained in:
Generated
+6132
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
||||
***NVM installieren***
|
||||
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||
|
||||
oder
|
||||
|
||||
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||
|
||||
***Node.js installieren***
|
||||
|
||||
nvm install --lts
|
||||
|
||||
***package.json***
|
||||
|
||||
npm install
|
||||
|
||||
***Rollup build***
|
||||
|
||||
einmalig:
|
||||
|
||||
npm run build
|
||||
|
||||
als watch bei Änderungen:
|
||||
|
||||
npm run watch
|
||||
@@ -0,0 +1,91 @@
|
||||
import babel from '@rollup/plugin-babel';
|
||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import vue from "rollup-plugin-vue";
|
||||
import { globSync } from 'glob';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import postcss from 'rollup-plugin-postcss';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
import alias from '@rollup/plugin-alias';
|
||||
import { existsSync } from 'node:fs';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
import json from '@rollup/plugin-json';
|
||||
|
||||
function FhcResolver () {
|
||||
return {
|
||||
name: 'fhc-resolver', // this name will show up in logs and errors
|
||||
resolveId ( source, importer, options ) {
|
||||
if( source.includes('.php') ) {
|
||||
return false;
|
||||
}
|
||||
//console.log('source: ' + source + ' options.isEntry: ' + options.isEntry + ' importer: ' + importer);
|
||||
if(importer !== undefined && !options.isEntry && !path.isAbsolute(source)) {
|
||||
let tmp = path.dirname(importer);
|
||||
if( importer.includes('/application/') ) {
|
||||
tmp = tmp.replace(/public\/js\//, 'js/').replace(/\/application\//, '/public/');
|
||||
}
|
||||
const resolved = path.resolve(tmp, source);
|
||||
//console.log(resolved);
|
||||
if( existsSync(resolved) ) {
|
||||
return resolved
|
||||
}
|
||||
}
|
||||
return null; // other ids should be handled as usually
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const useplugins = [
|
||||
alias({
|
||||
entries: {
|
||||
vue: 'vue/dist/vue.esm-bundler.js'
|
||||
}
|
||||
}),
|
||||
nodeResolve({
|
||||
preferBuiltins: true,
|
||||
moduleDirectories: ['node_modules'],
|
||||
modulePaths: globSync('application/extensions/*/node_modules', {follow: true, realpath: true}).map(file =>
|
||||
fileURLToPath(new URL(file, import.meta.url))
|
||||
),
|
||||
}),
|
||||
FhcResolver(),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
'process.env.NODE_ENV': JSON.stringify( 'production' ),
|
||||
}),
|
||||
commonjs(),
|
||||
vue(),
|
||||
json(),
|
||||
babel({
|
||||
babelHelpers: 'bundled',
|
||||
plugins: ['transform-class-properties']
|
||||
}),
|
||||
postcss({
|
||||
extract: false,
|
||||
modules: true,
|
||||
use: ['sass'],
|
||||
}),
|
||||
terser()
|
||||
];
|
||||
|
||||
export default globSync('public/**/js/apps/**/*.js', {follow: true, realpath: true}).map(file => {
|
||||
if( path.dirname(file).includes('/dist/') || path.dirname(file).includes('/apps/vbform') ) {
|
||||
return null;
|
||||
}
|
||||
let tmp = fileURLToPath(new URL(file, import.meta.url));
|
||||
return {
|
||||
input: tmp,
|
||||
plugins: useplugins,
|
||||
watch: {
|
||||
buildDelay: 500
|
||||
},
|
||||
output: {
|
||||
preserveModules: false,
|
||||
sourcemap: true,
|
||||
format: 'es',
|
||||
file: tmp.replace(/public\//, 'public/dist/'),
|
||||
}
|
||||
|
||||
}
|
||||
}).filter(Boolean);
|
||||
Reference in New Issue
Block a user