Skip to content

Commit

Permalink
Fixed AB#0334 support js and css file bundling (#29)
Browse files Browse the repository at this point in the history
* Introduces the first step of JS/CSS bundling

* npm audit fixed

* WiP and PoC: Added support for css globs

* Fixes AB#0334 to support individual globbing for multiple built css and js files

* Bumped semver

* - Added logic to handle CSS globs that was missing
  • Loading branch information
tforster authored Apr 10, 2021
1 parent 4ece430 commit 6f579bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ All released versions are available as [Releases on this repository](https://git

## History

`v0.9.0` **Support JS and CSS file bundling**
`v0.9.0` **Support JS and CSS file bundling** (2021-04-05)

Features

- [Support JS and CSS file bundling](https://dev.azure.com/techsmarts/TechSmarts/_workitems/edit/334)

Fixes

- [Published env variable logic is flipped](https://dev.azure.com/techsmarts/TechSmarts/_workitems/edit/762)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tforster/webproducer",
"version": "0.8.0",
"version": "0.9.0",
"description": "WebProducer, or simply WP, is a serverless application for publishing content to the web. It equally supports websites and web applications with a lean, streams based, architecture.",
"author": "",
"license": "MIT",
Expand Down
19 changes: 7 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,25 +200,20 @@ class WebProducer {
]);
looseFiles.name = "looseFiles";


// We ignored scripts above as they require unique handling here
const scriptStreams = Object.keys(this.globs.scripts).map(key => {
let scriptStream = srcStreamReadable.src(`${srcRoot}${this.globs.scripts[key]}`).pipe(concat(key)).pipe(terser()).pipe(sourcemaps.write("/"));
scriptStream.name = key;
return scriptStream;
})

// We ignored scripts above as they require unique handling here
// const scripts = srcStreamReadable.src(`${srcRoot}/**/*.js`).pipe(concat('main.js')).pipe(terser()).pipe(sourcemaps.write("/"));
// scripts.name = "scripts";

// We ignored stylesheets above as they require unique handling here
const stylesheets = srcStreamReadable
.src(`${srcRoot}/**/*.css`)
.pipe(sourcemaps.init())
.pipe(cleanCSS())
.pipe(concat("styles.css"))
.pipe(sourcemaps.write("/"));
stylesheets.name = "stylesheets";
const cssStreams = Object.keys(this.globs.styles).map(key => {
let cssStream = srcStreamReadable.src(`${srcRoot}${this.globs.styles[key]}`).pipe(cleanCSS()).pipe(concat(key)).pipe(sourcemaps.write("/"));
cssStream.name = key;
return cssStream;
})

// We ignored the stream of handlebars theme files as they were generated earlier and require additional unique handling here
const pagesStream = htmlStream.pipe(minifyHtml({ collapseWhitespace: true, removeComments: true }));
Expand All @@ -228,7 +223,7 @@ class WebProducer {
await destinationFilesParsed;

// Merge all the various input streams into one main stream to be parsed
const streams = [looseFiles, ...scriptStreams, stylesheets, pagesStream, fileStream];
const streams = [looseFiles, ...scriptStreams, ...cssStreams, pagesStream, fileStream];

// MergedStream is new in 0.5.0 and replaces the previous and more complicated Promise-based code block
const mergedStream = new MergeStream(streams);
Expand Down

0 comments on commit 6f579bb

Please sign in to comment.