WEBSDK: C8ycli: Using Image Assets with c8ycli serve (Webpack)

What product/components do you use and which version/fix level are you on?

c8y:1011.0.17

c8ycli (6.14.17)

Is your question related to the free trial, or to a production (customer) instance?

Production

What are you trying to achieve? Please describe it in detail.

When building a project using Angular CLI you can include assets by placing them in src/assets/ directory and they will automatically be copied to the build directory (when the application is built).

This is useful when including referenced images without manually copying assets into the build directory.
Additional assets folders can be specified in the angular.json file and these too will be copied over.

It’s not clear to me how this works with the c8ycli. Images can be manually copied to the dist directory after running c8ycli build. Although this is not possible when using c8ycli serve. Is there any ability to customise the webpack configuration to automatically copy a directory to the build location so it can be served by c8ycli?

Do you get any error messages? Please provide a full error message screenshot and log file.

N/A

Have you installed all the latest fixes for the products and systems you are using?

N/A

Hi Harrison,

you can specify an additional webpack configuration like this for the build or server command:

c8ycli build --env.extraWebpackConfig=./c8ycli-extra-webpack.config.js

The c8ycli-extra-webpack.config.js file could the look like this:

const CopyPlugin = require('copy-webpack-plugin');

module.exports = config;

function config(env) {
  'use strict';

  return {
    plugins: [
      new CopyPlugin([
        { from: './assets', to: 'assets' }
      ])
    ]
  };
}

Regards,
Tristan

1 Like

Thank You for the insight.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.