Skip to content

Commit c0e721a

Browse files
authored
chore: remove support for LESS (#18)
* chore: cleanup storybook config * chore: remove less styles * chore: remove less support from build
1 parent 4755e04 commit c0e721a

33 files changed

+2614
-2349
lines changed

.storybook/main.js

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,4 @@
1-
const path = require("path");
2-
const Theme = require("./theme");
3-
const TSDocgenPlugin = require("react-docgen-typescript-webpack-plugin");
4-
51
module.exports = {
62
stories: ["../packages/**/*.stories.[tj]sx", "../packages/**/*.stories.mdx"],
7-
addons: ["@storybook/addon-essentials", "@storybook/addon-links"],
8-
typescript: {
9-
typescript: {
10-
check: true,
11-
checkOptions: {},
12-
reactDocgen: "react-docgen-typescript",
13-
reactDocgenTypescriptOptions: {
14-
shouldExtractLiteralValuesFromEnum: true,
15-
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
16-
compilerOptions: {
17-
allowSyntheticDefaultImports: false,
18-
esModuleInterop: false,
19-
},
20-
},
21-
},
22-
},
23-
webpackFinal: async (config) => {
24-
config.module.rules.push({
25-
test: /\.(ts|tsx)$/,
26-
use: [
27-
{
28-
loader: require.resolve("babel-loader"),
29-
options: {
30-
cacheDirectory: true,
31-
presets: ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
32-
plugins: [
33-
["import", { libraryName: "antd", libraryDirectory: "lib", style: true }],
34-
["@babel/plugin-proposal-decorators", { legacy: true }],
35-
["@babel/plugin-proposal-class-properties", { loose: true }],
36-
],
37-
},
38-
},
39-
],
40-
});
41-
config.module.rules.push({
42-
test: /\.less$/,
43-
use: [
44-
"style-loader",
45-
"css-loader",
46-
{
47-
loader: "less-loader",
48-
options: {
49-
lessOptions: {
50-
javascriptEnabled: true,
51-
modifyVars: Theme,
52-
},
53-
},
54-
},
55-
],
56-
include: path.resolve(__dirname, "../"),
57-
});
58-
config.plugins.push(new TSDocgenPlugin());
59-
config.resolve.extensions.push(".ts", ".tsx");
60-
// Replaces the webpack rule that loads SVGs as static files to leave out SVG files for us to handle
61-
const indexOfRuleToRemove = config.module.rules.findIndex((rule) => rule.test.toString().includes("svg"));
62-
config.module.rules.splice(indexOfRuleToRemove, 1, {
63-
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,
64-
loader: require.resolve("file-loader"),
65-
options: {
66-
name: "static/media/[name].[hash:8].[ext]",
67-
esModule: false,
68-
},
69-
});
70-
71-
config.module.rules.push({
72-
test: /\.svg$/,
73-
use: [
74-
{
75-
loader: "@svgr/webpack",
76-
options: {
77-
svgoConfig: {
78-
plugins: [
79-
{
80-
removeViewBox: false,
81-
},
82-
],
83-
},
84-
},
85-
},
86-
],
87-
});
88-
return config;
89-
},
3+
addons: ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/preset-ant-design"],
904
};

.storybook/preview.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { addDecorator, addParameters } from "@storybook/react";
33
import sortEachDepth from "./sortEachDepth";
44
import { Provider, Themes } from "../packages/apsara-ui/src";
55

6-
// Apply global styles for storybook
7-
import "!style-loader!css-loader!less-loader!./storybook.less";
8-
import "../packages/apsara-ui/styles/app.less";
9-
106
addDecorator((story) => <div style={{ margin: "16px" }}>{story()}</div>);
117
addParameters({
128
options: {

.storybook/storybook.less

Lines changed: 0 additions & 84 deletions
This file was deleted.

.storybook/theme.js

Lines changed: 0 additions & 125 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
"@babel/preset-typescript": "^7.10.4",
2929
"@commitlint/cli": "^11.0.0",
3030
"@commitlint/config-conventional": "^11.0.0",
31+
"@storybook/addon-essentials": "^6.4.9",
32+
"@storybook/addon-links": "^6.4.9",
33+
"@storybook/preset-ant-design": "^0.0.2",
34+
"@storybook/react": "^6.4.9",
3135
"@testing-library/jest-dom": "^5.11.4",
3236
"@testing-library/react": "^11.0.4",
3337
"@types/node": "^14.10.1",

packages/apsara-ui/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@
5353
"devDependencies": {
5454
"@rollup/plugin-json": "^4.1.0",
5555
"@rollup/plugin-url": "^5.0.1",
56-
"@storybook/addon-controls": "^6.1.21",
57-
"@storybook/addon-essentials": "^6.1.21",
58-
"@storybook/addon-links": "^6.1.10",
59-
"@storybook/addon-storysource": "^6.1.10",
60-
"@storybook/react": "^6.1.10",
6156
"@svgr/rollup": "^5.4.0",
6257
"@svgr/webpack": "^5.4.0",
6358
"@types/react-window": "^1.8.2",
@@ -67,7 +62,6 @@
6762
"file-loader": "^6.1.1",
6863
"less": "^3.12.2",
6964
"less-loader": "^7.0.1",
70-
"react-docgen-typescript-webpack-plugin": "^1.1.0",
7165
"rollup": "^2.27.0",
7266
"rollup-plugin-multi-input": "^1.1.1",
7367
"rollup-plugin-peer-deps-external": "^2.2.3",

packages/apsara-ui/rollup.config.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ import multiInput from "rollup-plugin-multi-input";
33
import typescript from "rollup-plugin-typescript2";
44
import tsImportPluginFactory from "ts-import-plugin";
55
import peerDepsExternal from "rollup-plugin-peer-deps-external";
6-
import postcss from "rollup-plugin-postcss";
7-
import rollupPostcssLessLoader from "rollup-plugin-postcss-webpack-alias-less-loader";
86
import svgr from "@svgr/rollup";
97
import json from "@rollup/plugin-json";
108
import url from "@rollup/plugin-url";
119

12-
import Theme from "./theme";
13-
1410
export default {
1511
input: ["src/**/*.ts", "src/**/*.tsx", "!src/**/*.stories.[tj]s[x]", "!src/**/*.test.[tj]s[x]"],
1612
/*
@@ -43,22 +39,9 @@ export default {
4339
limit: Infinity,
4440
sourceDir: path.join(__dirname, "assets"),
4541
}),
46-
postcss({
47-
use: [["less", { javascriptEnabled: true, modifyVars: Theme }]],
48-
loaders: [
49-
rollupPostcssLessLoader({
50-
nodeModulePath: path.resolve(__dirname, "./node_modules"),
51-
aliases: {},
52-
options: {
53-
javascriptEnabled: true,
54-
},
55-
}),
56-
],
57-
}),
5842

5943
// Prevents Rollup from bundling the peer dependencies
6044
peerDepsExternal(),
61-
6245
// Transpiles our TypeScript code into JavaScript
6346
typescript({
6447
clean: true,
@@ -72,7 +55,7 @@ export default {
7255
before: tsImportPluginFactory({
7356
libraryName: "antd",
7457
libraryDirectory: "lib",
75-
style: true,
58+
style: "css",
7659
}),
7760
}),
7861
],

0 commit comments

Comments
 (0)