Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
MiniCssExtractPlugin can't reference async chucnks

I am using Vue with Webpack (without Vue CLI) and I ran into an issue. I am building a Design System library, in which I would like to have async chunks so they get small.

When I import as usual the component in the index.ts of the lib

//index.ts
import RedBox from '@/components/RedBox.vue';

export { RedBox };

everything works perfectly.

But when I try to do

const RedBox = () => import('@/components/RedBox.vue');

export { RedBox };

i get error message

The file is actually there in the bundle.

Here is my webpack config

/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = (env) => {
  const plugins = [
    new VueLoaderPlugin(),
    new CleanWebpackPlugin(),
    new MiniCssExtractPlugin({
      filename: 'assets/css/[name].css',
      chunkFilename: 'assets/css/[name].css',
    }),
  ];
  if (env.ANALYZE_BUNDLE) { plugins.push(new BundleAnalyzerPlugin()); }
  return {
    entry: './src/index.ts',
    mode: 'production',
    devtool: 'source-map',
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: 'design-system.js',
      library: {
        name: 'design-system',
        type: 'umd',
      },
    },
    module: {
      rules: [
        {
          test: /\.vue$/,
          loader: 'vue-loader',
        },
        {
          test: /\.ts?$/,
          loader: 'ts-loader',
          exclude: /node_modules/,
          options: {
            transpileOnly: true,
          },
        },
        {
          test: /\.(sa|sc|c)ss$/,
          use: [
            {
              loader: MiniCssExtractPlugin.loader,
              options: {},
            },
            'css-loader',
            'postcss-loader',
            {
              loader: 'sass-loader',
              options: {},
            },
          ],
        },
        {
          test: /\.(woff|woff2|eot|ttf|otf)$/i,
          type: 'asset/resource',
        },
      ],
    },
    plugins,
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
      },
      extensions: [
        '.vue',
        '.ts',
        '.js',
        '.css',
        '.ttf',
        '.otf',
      ],
    },
    externals: {
      vue: 'Vue',
    },
  };
};
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!