Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web-styles): publish the dist subdirectory #152

Merged
merged 1 commit into from Jul 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions packages/web-styles/gulpfile.js
@@ -1,10 +1,11 @@
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const sass = require('sass');
const gulpSass = require('gulp-sass')(sass);
const gulpPostCss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const options = require('./package.json').sass;

/*
* Copy task
*/
Expand All @@ -19,6 +20,27 @@ gulp.task("copy", () => {
.pipe(gulp.dest(options.outputDir));
});

/**
* Transform `package.json` of the published subdirectory
*
* @remarks removes `publishConfig.directory`.
* The publish command runs against `publishConfig.directory`, so keeping the original path
* would attempt publishing `web-styles/dist/dist` instead of `web-styles/dist`.
*
*/
gulp.task('transform-package-json', (done) => {
const packageJson = require('./package.json');

delete packageJson.publishConfig.directory;

fs.writeFileSync(
path.join(options.outputDir, 'package.json'),
JSON.stringify(packageJson, null, 2),
);

done();
});

/*
* Compile Scss to Css
* - Compile
Expand Down Expand Up @@ -65,5 +87,5 @@ gulp.task('watch', () => {
*/
exports.default = gulp.task(
"build",
gulp.parallel("copy", gulp.series("sass"))
gulp.parallel(gulp.series("copy", "transform-package-json"), gulp.series("sass"))
);