function chainWebpackLib()

in lex-web-ui/vue.config.js [101:186]


function chainWebpackLib(
  config,
  entryName = 'lex-web-ui',
  entryFileName = './src/lex-web-ui.js',
  destDir = 'bundle',
  libraryName = 'LexWebUi',
  format = 'umd',
) {
  const baseFilename = `${destDir}/${entryName}`;
  const filename = (buildType.isProd)
    ? `${baseFilename}.min.js` : `${baseFilename}.js`;

  config
    .entry(entryName)
    .add(entryFileName)
    .end()
    .output
    .libraryTarget(format)
    .library(libraryName)
    .filename(filename);

  chainWebpackCommon(config, destDir);

  config.externals([
    // XXX TODO need to add dependencies below to the lex-web-ui-loader
    // 'jsonwebtoken',
    // 'marked',
    'vue',
    'vuex',
    'vue-router',
    'vuetify',
    /^aws-sdk\/.+$/,
  ]);

  config.optimization.splitChunks({
    cacheGroups: {
      default: false,
    },
  });
  config.optimization.runtimeChunk(false);

  if (config.plugins.has('extract-css')) {
    config
      .plugin('extract-css')
      .tap((args) => {
        const cssFilename = (buildType.isProd)
          ? `${baseFilename}.min.css` : `${baseFilename}.css`;
        // eslint-disable-next-line no-param-reassign
        args[0].filename = cssFilename;
        return args;
      })
      .end();
  }

  if (config.plugins.has('html')) {
    config
      .plugin('html')
      .tap((args) => {
        // eslint-disable-next-line no-param-reassign
        args[0].filename = (buildType.isProd)
          ? `${destDir}/index.min.html` : `${destDir}/index.html`;
        return args;
      })
      .end();
  }

  config.plugin('define')
    .tap((args) => {
      // eslint-disable-next-line no-param-reassign
      args[0]['process.env'].BUILD_TARGET = `"${process.env.BUILD_TARGET}"`;
      return args;
    })
    .end();

  config.plugin('banner')
    .use(webpack.BannerPlugin, [{
      banner: `/*!
* lex-web-ui v${PACKAGE_VERSION}
* (c) 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Released under the Amazon Software License.
*/  `,
      raw: true,
      entryOnly: true,
      exclude: /[\\/]node_modules[\\/]/,
    }]);
}