Skip to content

Commit

Permalink
Merge pull request #3129 from salesforce-ux/chore/gulp-dist
Browse files Browse the repository at this point in the history
Refactor dist.js to use Gulp
  • Loading branch information
aputinski authored Mar 6, 2018
2 parents 789aa99 + 8f0a6ef commit 741c2a4
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 387 deletions.
39 changes: 38 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import glob from 'glob';
import gulp from 'gulp';
import path from 'path';
import touch from 'touch';
import webpack from 'webpack';
import { argv } from 'yargs';

import * as accessibility from './scripts/gulp/accessibility';
import * as dist from './scripts/gulp/dist';
import * as examples from './scripts/gulp/generate/examples';
import * as tokens from './scripts/gulp/generate/tokens';
import * as lint from './scripts/gulp/lint';
Expand Down Expand Up @@ -183,6 +183,42 @@ export const watch = () =>
});
});

// /////////////////////////////////////////////////////////
// Dist
// /////////////////////////////////////////////////////////

gulp.task(
'dist',
gulp.series(
withName('dist:clean:before')(dist.cleanBefore),
gulp.parallel(
withName('dist:copyRoot')(dist.copyRoot),
withName('dist:copySass')(dist.copySass),
withName('dist:copySassLicense')(dist.copySassLicense),
withName('dist:copyIcons')(dist.copyIcons),
withName('dist:copyIconsMeta')(dist.copyIconsMeta),
withName('dist:copyFonts')(dist.copyFonts),
withName('dist:copyFontsLicense')(dist.copyFontsLicense),
withName('dist:copyImages')(dist.copyImages),
withName('dist:copyImagesLicense')(dist.copyImagesLicense),
withName('dist:copySwatches')(dist.copySwatches),
withName('dist:copyDesignTokens')(dist.copyDesignTokens),
withName('dist:copyComponentDesignTokens')(dist.copyComponentDesignTokens)
),
withName('dist:sass')(dist.sass),
withName('dist:minifyCss')(dist.minifyCss),
gulp.parallel(
withName('dist:versionBlock')(dist.versionBlock),
withName('dist:versionInline')(dist.versionInline),
withName('dist:buildInfo')(dist.buildInfo),
withName('dist:writeUI')(dist.writeUI),
withName('dist:writeLibrary')(dist.writeLibrary),
withName('dist:packageJson')(dist.packageJson)
),
withName('dist:clean:after')(dist.cleanAfter)
)
);

// /////////////////////////////////////////////////////////
// Travis
// /////////////////////////////////////////////////////////
Expand All @@ -196,6 +232,7 @@ gulp.task('travis', done => {
'generate:examples:wrapped',
withName('travis:snapshots')(travis.createSnapshots),
withName('travis:lint:examples')(travis.lintExamples),
'dist',
withName('travis:publish')(travis.publishBuild)
)(done);
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"stylestats": "7.0.1",
"temp": "0.8.3",
"theo": "6.0.0-beta.2",
"thread-loader": "1.1.5",
"through2": "2.0.3",
"tinycolor2": "1.4.1",
"touch": "3.1.0",
Expand Down
30 changes: 30 additions & 0 deletions scripts/compile/__tests__/__snapshots__/bundle.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ exports[`doesn't change configs 1`] = `
\\"test\\": {
},
\\"use\\": [
{
\\"loader\\": \\"thread-loader\\",
\\"options\\": {
}
},
{
\\"loader\\": \\"babel-loader\\",
\\"options\\": {
Expand Down Expand Up @@ -48,6 +53,11 @@ exports[`doesn't change configs 1`] = `
\\"test\\": {
},
\\"use\\": [
{
\\"loader\\": \\"thread-loader\\",
\\"options\\": {
}
},
{
\\"loader\\": \\"babel-loader\\",
\\"options\\": {
Expand Down Expand Up @@ -103,6 +113,11 @@ exports[`doesn't change configs 1`] = `
\\"test\\": {
},
\\"use\\": [
{
\\"loader\\": \\"thread-loader\\",
\\"options\\": {
}
},
{
\\"loader\\": \\"babel-loader\\",
\\"options\\": {
Expand Down Expand Up @@ -139,6 +154,11 @@ exports[`doesn't change configs 1`] = `
\\"test\\": {
},
\\"use\\": [
{
\\"loader\\": \\"thread-loader\\",
\\"options\\": {
}
},
{
\\"loader\\": \\"babel-loader\\",
\\"options\\": {
Expand Down Expand Up @@ -202,6 +222,11 @@ exports[`doesn't change configs 1`] = `
\\"test\\": {
},
\\"use\\": [
{
\\"loader\\": \\"thread-loader\\",
\\"options\\": {
}
},
{
\\"loader\\": \\"babel-loader\\",
\\"options\\": {
Expand Down Expand Up @@ -238,6 +263,11 @@ exports[`doesn't change configs 1`] = `
\\"test\\": {
},
\\"use\\": [
{
\\"loader\\": \\"thread-loader\\",
\\"options\\": {
}
},
{
\\"loader\\": \\"babel-loader\\",
\\"options\\": {
Expand Down
5 changes: 3 additions & 2 deletions scripts/compile/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ const compile = configs =>

const compileLibrary = () => configs.chain(compile);

const writeManifest = () =>
const writeManifest = stats =>
manifest
.map(m => JSON.stringify(m, null, 2))
.chain(contents =>
writeFile(path.join(paths.dist, 'manifest.json'), contents)
);
)
.map(() => stats);

// createLibrary :: () -> Task Error (List Stats)
const createLibrary = () => compileLibrary().chain(writeManifest);
Expand Down
8 changes: 8 additions & 0 deletions scripts/compile/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = I.fromJS({
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'thread-loader',
options: {}
},
{
loader: 'babel-loader',
options: {
Expand All @@ -39,6 +43,10 @@ module.exports = I.fromJS({
test: /\.mdx$/,
exclude: /node_modules/,
use: [
{
loader: 'thread-loader',
options: {}
},
{
loader: 'babel-loader',
options: {
Expand Down
Loading

0 comments on commit 741c2a4

Please sign in to comment.