Raghav
Raghav

Reputation: 1229

How to create a single bundle with CSS and JS files?

I'm creating web components in Angular by grabbing .js files which include runtime.js, polyfills.js and main.js and concatenating them into single file called list.js by using below code

const fs = require('fs-extra');
const concat = require('concat');

(async function build() {

    const files = [
        './dist/dls-webcomponents/runtime.js',
        './dist/dls-webcomponents/polyfills.js',
        './dist/dls-webcomponents/main.js'             
    ]

    await fs.ensureDir('elements')

    await concat(files, 'elements/list.js')

})()

angular.json

"scripts": {
     ...
    "build:elements": "ng build --prod --output-hashing none && node build-helper.js "
  }

While generating the production build angular is creating above .js files along with styles.css file.

Is there anyway that I can include this styles in above list.js file?

Upvotes: 4

Views: 832

Answers (0)

Related Questions