Skip to content

Commit

Permalink
feat: only use rollup output for build (betaflight#3597)
Browse files Browse the repository at this point in the history
chore: reduce final package build output
  • Loading branch information
chmelevskij committed Apr 27, 2024
1 parent 868404e commit 9d66d39
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
37 changes: 23 additions & 14 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,19 @@ function process_package_debug(done) {
getGitRevision(done, processPackage, false);
}

// dist_yarn MUST be done after dist_src

const distCommon = gulp.series(dist_src, dist_less, dist_changelog, dist_yarn, dist_locale, dist_libraries, dist_resources, dist_rollup, gulp.series(cordova_dist()));
const distCommon = gulp.series(
dist_src,
dist_node_modules_css,
dist_less,
dist_changelog,
dist_locale,
dist_libraries,
dist_resources,
dist_rollup,
gulp.series(
cordova_dist(),
),
);

const distBuild = gulp.series(process_package_release, distCommon);

Expand Down Expand Up @@ -344,38 +354,37 @@ function processPackage(done, gitRevision, isReleaseBuild) {
function dist_src() {
const distSources = [
'./src/**/*',
'!./src/**/*.js',
'!./src/**/*.vue',
'!./src/css/dropdown-lists/LICENSE',
'!./src/support/**',
'!./src/**/*.less',
'./src/js/workers/hex_parser.js',
];

return gulp.src(distSources, { base: 'src' })
.pipe(gulp.src('yarn.lock'))
.pipe(gulp.dest(DIST_DIR));
}

function dist_node_modules_css() {
return gulp.src('./**/*.min.css')
.pipe(gulp.dest(DIST_DIR));
}

function dist_less() {
return gulp.src('./src/**/*.less')
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(`${DIST_DIR}`));
.pipe(gulp.dest(DIST_DIR));
}

function dist_changelog() {
return gulp.src('changelog.html')
.pipe(gulp.dest(`${DIST_DIR}tabs/`));
}

// This function relies on files from the dist_src function
function dist_yarn() {
return gulp.src([`${DIST_DIR}package.json`, `${DIST_DIR}yarn.lock`])
.pipe(gulp.dest(DIST_DIR))
.pipe(yarn({
production: true,
}));
}

function dist_locale() {
return gulp.src('./locales/**/*', { base: 'locales'})
.pipe(gulp.dest(`${DIST_DIR}locales`));
Expand All @@ -400,6 +409,7 @@ function dist_rollup() {

return rollup
.rollup({
strictDeprecations: true,
input: {
// For any new file migrated to modules add the output path
// in dist on the left, on the right it's input file path.
Expand Down Expand Up @@ -441,7 +451,6 @@ function dist_rollup() {
// we want to see code in the same way as it
// is in the source files while debugging
sourcemap: true,
// put any 3rd party module in vendor.js
manualChunks(id) {
/**
* This splits every npm module loaded in into it's own package
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"nw-builder": "3.8.3",
"os": "^0.1.2",
"postcss": "^8.4.31",
"rollup": "^3.9.0",
"rollup": "^3.29.4",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-vue": "^5.*.*",
"rpm-builder": "^1.2.1",
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13263,13 +13263,20 @@ rollup-pluginutils@^2.8.2:
dependencies:
estree-walker "^0.6.1"

rollup@^3.27.1, rollup@^3.9.0:
rollup@^3.27.1:
version "3.29.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.0.tgz#1b40e64818afc979c7e5bef93de675829288986b"
integrity sha512-nszM8DINnx1vSS+TpbWKMkxem0CDWk3cSit/WWCBVs9/JZ1I/XLwOsiUglYuYReaeWWSsW9kge5zE5NZtf/a4w==
optionalDependencies:
fsevents "~2.3.2"

rollup@^3.29.4:
version "3.29.4"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.4.tgz#4d70c0f9834146df8705bfb69a9a19c9e1109981"
integrity sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==
optionalDependencies:
fsevents "~2.3.2"

rpm-builder@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/rpm-builder/-/rpm-builder-1.2.1.tgz#94655088266ec213f474efec0a9d9034404d0331"
Expand Down

0 comments on commit 9d66d39

Please sign in to comment.