This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Excluding features not reducing bundle size #97
Copy link
Copy link
Closed
Labels
Description
Hello!
No matter how many features I try to include/exclude, my monaco bundle size remains the same. I'm wondering if it's because I'm using cacheGroups to create a separate monaco bundle?
splitChunks: {
cacheGroups: {
monaco: {
test: /[\\/]node_modules[\\/]monaco-editor/,
name: "mc-monaco",
chunks: "all",
priority: 1,
},
Let me know if I'm missing something obvious, thanks!
Webpack config in full below:
const path = require("path");
const webpack = require("webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const WebpackAssetsManifest = require("webpack-assets-manifest");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
module.exports = {
mode: "production",
entry: {
mc: "./src/index.tsx",
},
output: {
// "filename" must match what we tell MonacoWebpackPlugin
filename: "[name].[contenthash].bundle.js",
sourceMapFilename: "[name].[contenthash].map",
path: path.join(__dirname, "dist"),
},
optimization: {
moduleIds: "hashed",
runtimeChunk: {
name: "mc-runtime",
},
splitChunks: {
cacheGroups: {
monaco: {
test: /[\\/]node_modules[\\/]monaco-editor/,
name: "mc-monaco",
chunks: "all",
priority: 1,
},
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "mc-vendor",
chunks: "all",
},
},
},
},
module: {
rules: [
{
test: /\.ts|\.tsx$/,
include: path.join(__dirname, "src"),
// We need babel in particular because of the transform-react-display-name
// (part of the react preset), which helps in debugging.
use: [
{
loader: "babel-loader",
options: {
cacheDirectory: true,
},
},
{
loader: "awesome-typescript-loader",
},
],
},
{
test: /\.js$/,
include: path.join(__dirname, "src"),
use: [
{
loader: "babel-loader",
options: {
cacheDirectory: true,
},
},
],
},
{
test: /\.css$/,
include: [
path.join(__dirname, "src"),
path.join(
__dirname,
"node_modules",
"github-markdown-css",
"github-markdown.css",
),
],
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1,
},
},
"postcss-loader",
],
},
// --- Loaders for monaco ---
{
test: /\.ts?$/,
include: path.join(__dirname, "node_modules", "monaco-editor"),
use: ["awesome-typescript-loader"],
},
{
test: /\.css$/,
include: path.join(__dirname, "node_modules", "monaco-editor"),
use: ["style-loader", "css-loader"],
},
{
test: /\.ttf$/,
include: path.join(__dirname, "node_modules", "monaco-editor"),
use: ["file-loader"],
},
// ---
],
},
resolve: {
extensions: [".tsx", ".ts", ".jsx", ".js"],
},
devtool: "source-map",
plugins: [
new MonacoWebpackPlugin({
// "filename" must match what we configure in output
filename: "[name].[contenthash].bundle.js",
languages: ["markdown"],
features: [
"!accessibilityHelp",
"!bracketMatching",
"!caretOperations",
"!clipboard",
"!codeAction",
"!codelens",
"!colorDetector",
"!comment",
"!contextmenu",
"!cursorUndo",
"!dnd",
"!folding",
"!fontZoom",
"!format",
"!gotoError",
"!gotoLine",
"!gotoSymbol",
"!hover",
"!iPadShowKeyboard",
"!inPlaceReplace",
"!inspectTokens",
"!linesOperations",
"!links",
"!multicursor",
"!parameterHints",
"!quickCommand",
"!quickOutline",
"!referenceSearch",
"!rename",
"!smartSelect",
"!snippets",
"!suggest",
"!toggleHighContrast",
"!toggleTabFocusMode",
"!transpose",
"!wordHighlighter",
"!wordOperations",
"!wordPartOperations",
],
}),
],
};