Skip to content

Commit 41cce41

Browse files
DanielJGeigerJauhen
authored andcommitted
chore: Update @excalidraw/extensions configs.
1 parent 8dfd402 commit 41cce41

File tree

5 files changed

+994
-64
lines changed

5 files changed

+994
-64
lines changed

packages/extensions/package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@excalidraw/extensions",
3-
"version": "0.12.0",
3+
"version": "0.15.2",
44
"main": "index.ts",
55
"files": [
66
"dist/*"
@@ -38,8 +38,8 @@
3838
]
3939
},
4040
"peerDependencies": {
41-
"react": "^18.2.0",
42-
"react-dom": "^18.2.0"
41+
"react": "^17.0.2 || ^18.2.0",
42+
"react-dom": "^17.0.2 || ^18.2.0"
4343
},
4444
"devDependencies": {
4545
"@babel/core": "7.18.9",
@@ -50,19 +50,23 @@
5050
"@babel/preset-env": "7.18.6",
5151
"@babel/preset-react": "7.18.6",
5252
"@babel/preset-typescript": "7.18.6",
53+
"@size-limit/preset-big-lib": "8.2.6",
5354
"autoprefixer": "10.4.7",
5455
"babel-loader": "8.2.5",
5556
"babel-plugin-transform-class-properties": "6.24.1",
5657
"cross-env": "7.0.3",
5758
"css-loader": "6.7.1",
5859
"dotenv": "16.0.1",
60+
"import-meta-loader": "1.1.0",
5961
"mini-css-extract-plugin": "2.6.1",
6062
"postcss-loader": "7.0.1",
6163
"sass-loader": "13.0.2",
64+
"size-limit": "8.2.4",
65+
"style-loader": "3.3.3",
6266
"terser-webpack-plugin": "5.3.3",
6367
"ts-loader": "9.3.1",
64-
"typescript": "4.7.4",
65-
"webpack": "5.73.0",
68+
"typescript": "4.9.4",
69+
"webpack": "5.76.0",
6670
"webpack-bundle-analyzer": "4.5.0",
6771
"webpack-cli": "4.10.0",
6872
"webpack-dev-server": "4.9.3",
@@ -78,7 +82,8 @@
7882
"start": "webpack serve --config webpack.dev-server.config.js",
7983
"install:deps": "yarn install --frozen-lockfile && yarn --cwd ../../../",
8084
"build:deps": "yarn --cwd ../excalidraw cross-env NODE_ENV=development webpack --config webpack.dev.config.js",
81-
"build:example": "EXAMPLE=true webpack --config webpack.dev-server.config.js && yarn gen:types"
85+
"build:example": "EXAMPLE=true webpack --config webpack.dev-server.config.js && yarn gen:types",
86+
"size": "yarn build:umd && size-limit"
8287
},
8388
"dependencies": {
8489
"mathjax-full": "3.2.2"

packages/extensions/webpack.dev.config.js

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,101 @@
1-
global.__childdir = __dirname;
21
const path = require("path");
3-
const { merge } = require("webpack-merge");
4-
const commonConfig = require("../common.webpack.dev.config");
2+
const webpack = require("webpack");
3+
const autoprefixer = require("autoprefixer");
4+
const { parseEnvVariables } = require("./env");
55

66
const outputDir = process.env.EXAMPLE === "true" ? "example/public" : "dist";
7-
const config = {
7+
module.exports = {
8+
mode: "development",
9+
devtool: false,
810
entry: {
911
"excalidraw-extensions.development": "./index.ts",
1012
},
1113
output: {
1214
path: path.resolve(__dirname, outputDir),
1315
library: "ExcalidrawExtensionsLib",
16+
libraryTarget: "umd",
17+
filename: "[name].js",
1418
chunkFilename: "excalidraw-extensions-assets-dev/[name]-[contenthash].js",
1519
assetModuleFilename: "excalidraw-extensions-assets-dev/[name][ext]",
20+
21+
publicPath: "",
22+
},
23+
resolve: {
24+
extensions: [".js", ".ts", ".tsx", ".css", ".scss"],
25+
},
26+
module: {
27+
rules: [
28+
{
29+
test: /\.(sa|sc|c)ss$/,
30+
exclude: /node_modules/,
31+
use: [
32+
"style-loader",
33+
{ loader: "css-loader" },
34+
{
35+
loader: "postcss-loader",
36+
options: {
37+
postcssOptions: {
38+
plugins: [autoprefixer()],
39+
},
40+
},
41+
},
42+
"sass-loader",
43+
],
44+
},
45+
{
46+
test: /\.(ts|tsx|js|jsx|mjs)$/,
47+
exclude:
48+
/node_modules\/(?!(browser-fs-access|canvas-roundrect-polyfill))/,
49+
use: [
50+
{
51+
loader: "import-meta-loader",
52+
},
53+
{
54+
loader: "ts-loader",
55+
options: {
56+
transpileOnly: true,
57+
configFile: path.resolve(__dirname, "../tsconfig.dev.json"),
58+
},
59+
},
60+
],
61+
},
62+
{
63+
test: /\.(woff|woff2|eot|ttf|otf)$/,
64+
type: "asset/resource",
65+
},
66+
],
67+
},
68+
optimization: {
69+
splitChunks: {
70+
chunks: "async",
71+
cacheGroups: {
72+
vendors: {
73+
test: /[\\/]node_modules[\\/]/,
74+
name: "vendor",
75+
},
76+
},
77+
},
78+
},
79+
plugins: [
80+
new webpack.EvalSourceMapDevToolPlugin({ exclude: /vendor/ }),
81+
new webpack.DefinePlugin({
82+
"process.env": parseEnvVariables(
83+
path.resolve(__dirname, "../../../.env.development"),
84+
),
85+
}),
86+
],
87+
externals: {
88+
react: {
89+
root: "React",
90+
commonjs2: "react",
91+
commonjs: "react",
92+
amd: "react",
93+
},
94+
"react-dom": {
95+
root: "ReactDOM",
96+
commonjs2: "react-dom",
97+
commonjs: "react-dom",
98+
amd: "react-dom",
99+
},
16100
},
17101
};
18-
module.exports = merge(commonConfig, config);

packages/extensions/webpack.prod.config.js

Lines changed: 112 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,124 @@
1-
global.__childdir = __dirname;
21
const path = require("path");
3-
const { merge } = require("webpack-merge");
4-
const commonConfig = require("../common.webpack.prod.config");
2+
const TerserPlugin = require("terser-webpack-plugin");
3+
const BundleAnalyzerPlugin =
4+
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5+
const autoprefixer = require("autoprefixer");
6+
const webpack = require("webpack");
7+
const { parseEnvVariables } = require("./env");
58

6-
const config = {
9+
module.exports = {
10+
mode: "production",
711
entry: {
812
"excalidraw-extensions.production.min": "./index.ts",
913
},
1014
output: {
1115
path: path.resolve(__dirname, "dist"),
1216
library: "ExcalidrawExtensionsLib",
17+
libraryTarget: "umd",
18+
filename: "[name].js",
1319
chunkFilename: "excalidraw-extensions-assets/[name]-[contenthash].js",
1420
assetModuleFilename: "excalidraw-extensions-assets/[name][ext]",
21+
publicPath: "",
22+
},
23+
resolve: {
24+
extensions: [".js", ".ts", ".tsx", ".css", ".scss"],
25+
},
26+
module: {
27+
rules: [
28+
{
29+
test: /\.(sa|sc|c)ss$/,
30+
exclude: /node_modules/,
31+
use: [
32+
"style-loader",
33+
{
34+
loader: "css-loader",
35+
},
36+
{
37+
loader: "postcss-loader",
38+
options: {
39+
postcssOptions: {
40+
plugins: [autoprefixer()],
41+
},
42+
},
43+
},
44+
"sass-loader",
45+
],
46+
},
47+
{
48+
test: /\.(ts|tsx|js|jsx|mjs)$/,
49+
exclude:
50+
/node_modules\/(?!(browser-fs-access|canvas-roundrect-polyfill))/,
51+
52+
use: [
53+
{
54+
loader: "import-meta-loader",
55+
},
56+
{
57+
loader: "ts-loader",
58+
options: {
59+
transpileOnly: true,
60+
configFile: path.resolve(__dirname, "../tsconfig.prod.json"),
61+
},
62+
},
63+
{
64+
loader: "babel-loader",
65+
options: {
66+
presets: [
67+
"@babel/preset-env",
68+
["@babel/preset-react", { runtime: "automatic" }],
69+
"@babel/preset-typescript",
70+
],
71+
plugins: [
72+
"transform-class-properties",
73+
"@babel/plugin-transform-runtime",
74+
],
75+
},
76+
},
77+
],
78+
},
79+
{
80+
test: /\.(woff|woff2|eot|ttf|otf)$/,
81+
type: "asset/resource",
82+
},
83+
],
84+
},
85+
optimization: {
86+
minimize: true,
87+
minimizer: [
88+
new TerserPlugin({
89+
test: /\.js($|\?)/i,
90+
}),
91+
],
92+
splitChunks: {
93+
chunks: "async",
94+
cacheGroups: {
95+
vendors: {
96+
test: /[\\/]node_modules[\\/]/,
97+
name: "vendor",
98+
},
99+
},
100+
},
101+
},
102+
plugins: [
103+
...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []),
104+
new webpack.DefinePlugin({
105+
"process.env": parseEnvVariables(
106+
path.resolve(__dirname, "../../../.env.production"),
107+
),
108+
}),
109+
],
110+
externals: {
111+
react: {
112+
root: "React",
113+
commonjs2: "react",
114+
commonjs: "react",
115+
amd: "react",
116+
},
117+
"react-dom": {
118+
root: "ReactDOM",
119+
commonjs2: "react-dom",
120+
commonjs: "react-dom",
121+
amd: "react-dom",
122+
},
15123
},
16124
};
17-
module.exports = merge(commonConfig, config);

0 commit comments

Comments
 (0)