Use script to load js files dynamically. Why is the CSS extracted from the corresponding mini-css-extract-plugin not automatically loaded

Viewed 27

I use these:

webpack: 4.41.2;

vue: 2.6.11;

mini-css-extract-plugin: 1.3.5;

I use two.vue files as entry files

{
  entry: {
    view: join(__dirname, '../src/index.vue'),
    edit: join(__dirname, '../editor/index.vue')
  },
  output: {
    path: path.join(__dirname, '../dist'),
    library: `[name]-${uuid}-${version}`,
    libraryTarget: 'umd',
    filename: `${version}-[name].js`,
  },
}

I'm using the mini-CSs-extract-plugin to extract the CSS file

loader

{
        test: /\.less$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader
          },
          // 'vue-style-loader',
          'css-loader',
          'postcss-loader',
          'less-loader',
        ]
      },
      {
        test: /\.css$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader
          },
          // 'vue-style-loader',
          'css-loader',
          'postcss-loader'
        ]
      },

plugins:

plugins: [
    // new webpack.NoEmitOnErrorsPlugin(),
    // new webpack.NamedModulesPlugin(),
    new MiniCssExtractPlugin(),
    new VueLoaderPlugin()
  ],

The packaged files are as follows:

enter image description here

When I load 1.9.6-edit.js or 1.9.6-view.js at another site manually by document.createElement('script'), The corresponding edit.css/view.css are not automatically added to the page

What should I do?

0 Answers
Related