Skip to content

Commit

Permalink
chore: add rsdoctor example (#19)
Browse files Browse the repository at this point in the history
* chore: add doctor

* fix(rsdoctor): change loader config (#20)

---------

Co-authored-by: yifancong <easy_cong@126.com>
  • Loading branch information
hardfist and easy1090 authored Feb 2, 2024
1 parent 88eab6c commit f89767f
Show file tree
Hide file tree
Showing 192 changed files with 134 additions and 125 deletions.
1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ packages:
- "rsbuild/*"
- "rspress/*"
- "modernjs/*"
- "rsdoctor/*"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"private": true,
"scripts": {
"dev": "rspack serve",
"doctor": "RSDOCTOR=true rspack serve",
"build": "rspack build",
"analyze": "pnpm run build --analyze",
"preview": "cd dist && serve -s",
Expand Down Expand Up @@ -53,7 +54,8 @@
"react-refresh": "^0.14.0",
"serve": "14.1.2",
"style-loader": "^3.3.1",
"swc-loader": "^0.2.3"
"swc-loader": "^0.2.3",
"@rsdoctor/rspack-plugin": "0.1.0"
},
"browserslist": {
"production": [
Expand All @@ -73,4 +75,4 @@
}
},
"rspack": {}
}
}
File renamed without changes.
File renamed without changes.
129 changes: 129 additions & 0 deletions rsdoctor/arco-pro/rspack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
const path = require("path");
const rspack = require("@rspack/core");
const { RsdoctorRspackPlugin } = require("@rsdoctor/rspack-plugin");
const ReactRefreshPlugin = require("@rspack/plugin-react-refresh");
const { default: HtmlPlugin } = require("@rspack/plugin-html");

const prod = process.env.NODE_ENV === "production";

/** @type {import('@rspack/cli').Configuration} */
const config = {
context: __dirname,
entry: "./src/index.tsx",
target: ["web", "es5"],
devtool: false,
devServer: {
port: 5555,
webSocketServer: "sockjs",
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.less$/,
use: "less-loader",
type: "css",
},
{
test: /\.module\.less$/,
use: "less-loader",
type: "css/module",
},
{
test: /\.svg$/,
use: "@svgr/webpack",
},
{
test: /\.(j|t)s$/,
exclude: [/[\\/]node_modules[\\/]/],
use: {
loader: "builtin:swc-loader",
options: {
sourceMap: false,
jsc: {
parser: {
syntax: "typescript",
},
externalHelpers: true,
},
env: {
targets: "Chrome >= 48",
},
},
}
},
{
test: /\.(j|t)sx$/,
exclude: [/[\\/]node_modules[\\/]/],
use: {
loader: "builtin:swc-loader",
options: {
sourceMap: false,
jsc: {
parser: {
syntax: "typescript",
tsx: true,
},
transform: {
react: {
runtime: "automatic",
development: !prod,
refresh: !prod,
},
},
externalHelpers: true,
},
env: {
targets: "Chrome >= 48",
},
},
}
},
{
test: /\.png$/,
type: "asset",
},
],
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
// The default exported mock.js contains a minified [parser](https://github.com/nuysoft/Mock/blob/refactoring/src/mock/regexp/parser.js) with super deep binary
// expression, which causes stack overflow for swc parser in debug mode.
// Alias to the unminified version mitigates this problem.
// See also <https://github.com/search?q=repo%3Aswc-project%2Fswc+parser+stack+overflow&type=issues>
mockjs: require.resolve("./patches/mock.js"),
},
extensions: ["...", ".ts", ".tsx", ".jsx"],
},
output: {
publicPath: "/",
filename: "[name].[contenthash].js",
},
optimization: {
minimize: false, // Disabling minification because it takes too long on CI
realContentHash: true,
splitChunks: {
cacheGroups: {
someVendor: {
chunks: "all",
minChunks: 2,
},
},
},
},
plugins: [
new HtmlPlugin({
title: "Arco Pro App",
template: path.join(__dirname, "index.html"),
favicon: path.join(__dirname, "public", "favicon.ico"),
}),
new ReactRefreshPlugin(),
new rspack.ProgressPlugin(),
process.env.RSDOCTOR && new RsdoctorRspackPlugin(),
],
infrastructureLogging: {
debug: false,
},
};
module.exports = config;
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
123 changes: 0 additions & 123 deletions rspack/arco-pro/rspack.config.js

This file was deleted.

0 comments on commit f89767f

Please sign in to comment.