generated from gravity-ui/package-example
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vladimir Chernitsyn
authored
Mar 15, 2023
1 parent
4bd625f
commit c49a36e
Showing
4 changed files
with
2,996 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ node_modules | |
|
||
# Artifacts | ||
dist | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* eslint-env node */ | ||
const path = require('path'); | ||
const {task, src, dest, series, parallel} = require('gulp'); | ||
const rimraf = require('rimraf'); | ||
const ts = require('gulp-typescript'); | ||
const replace = require('gulp-replace'); | ||
const sass = require('gulp-dart-sass'); | ||
|
||
const BUILD_DIR = path.resolve('build'); | ||
|
||
task('clean', (done) => { | ||
rimraf.sync(BUILD_DIR); | ||
rimraf.sync('styles/**/*.css'); | ||
done(); | ||
}); | ||
|
||
function compileTs(modules = false) { | ||
const tsProject = ts.createProject('tsconfig.json', { | ||
declaration: true, | ||
module: modules ? 'esnext' : 'commonjs', | ||
}); | ||
|
||
return src([ | ||
'src/**/*.{ts,tsx}', | ||
'!src/demo/**/*', | ||
'!src/stories/**/*', | ||
'!src/**/__stories__/**/*', | ||
'!src/**/__tests__/**/*', | ||
]) | ||
.pipe( | ||
replace(/import '.+\.scss';/g, (match) => | ||
modules ? match.replace('.scss', '.css') : '', | ||
), | ||
) | ||
.pipe(tsProject()) | ||
.pipe(dest(path.resolve(BUILD_DIR, modules ? 'esm' : 'cjs'))); | ||
} | ||
|
||
task('compile-to-esm', () => { | ||
return compileTs(true); | ||
}); | ||
|
||
task('compile-to-cjs', () => { | ||
return compileTs(); | ||
}); | ||
|
||
task('copy-i18n', () => { | ||
return src(['src/**/i18n/*.json']) | ||
.pipe(dest(path.resolve(BUILD_DIR, 'esm'))) | ||
.pipe(dest(path.resolve(BUILD_DIR, 'cjs'))); | ||
}); | ||
|
||
task('styles-components', () => { | ||
return src(['src/components/**/*.scss', '!src/components/**/__stories__/**/*']) | ||
.pipe( | ||
sass({ | ||
includePaths: ['node_modules'], | ||
}), | ||
) | ||
.pipe(sass().on('error', sass.logError)) | ||
.pipe(dest(path.resolve(BUILD_DIR, 'esm', 'components'))) | ||
.pipe(dest(path.resolve(BUILD_DIR, 'cjs', 'components'))); | ||
}); | ||
|
||
task( | ||
'build', | ||
series([ | ||
'clean', | ||
parallel(['compile-to-esm', 'compile-to-cjs']), | ||
'copy-i18n', | ||
parallel(['styles-components']), | ||
]), | ||
); | ||
|
||
task('default', series(['build'])); |
Oops, something went wrong.