const CracoLessPlugin = require('craco-less') const HtmlWebpackPlugin = require('html-webpack-plugin') const path = require('path') module.exports = { plugins: [ { plugin: CracoLessPlugin, }, ], webpack: { configure: (webpackConfig) => { webpackConfig.entry = { main: path.resolve(__dirname, './src/index.tsx'), activetion: path.resolve(__dirname, './src/entries/demo/index.tsx'), } webpackConfig.output = { ...webpackConfig.output, filename: 'static/js/[name].[contenthash:8].js', chunkFilename: 'static/js/[name].[contenthash:8].chunk.js', } webpackConfig.plugins.forEach((plugin) => { if (plugin.constructor.name === 'HtmlWebpackPlugin') { plugin.userOptions.excludeChunks = ['demo'] } }) webpackConfig.plugins.push( new HtmlWebpackPlugin({ inject: true, template: path.resolve(__dirname, './public/demo.html'), chunks: ['demo'], filename: 'demo.html', }), ) return webpackConfig }, }, } 已解决