Skip to content

Commit

Permalink
refactor: all less files @import use /src/... path
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidZORO committed Mar 23, 2021
1 parent c36f44f commit b9afbc9
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 14 deletions.
9 changes: 8 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ module.exports = function (api) {
presets: [['next/babel']],
plugins: [
['import', { libraryName: 'antd', style: true }],
['module-resolver', { alias: { '@': './src' } }],
[
'module-resolver',
{
alias: {
'@': './src',
},
},
],
],
};
};
2 changes: 1 addition & 1 deletion src/components/FooterNav/style.module.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../styles/variables.less';
@import '/src/styles/variables.less';

.comp-wrapper {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderNavbar/style.module.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../styles/variables.less';
@import '/src/styles/variables.less';

.comp-wrapper {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/components/HugeIcon/style.module.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../styles/variables.less';
@import '/src/styles/variables.less';

.comp-wrapper {
transition: all 0.3s;
Expand Down
2 changes: 1 addition & 1 deletion src/components/LazyLoadingSpin/style.module.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../styles/variables.less';
@import '/src/styles/variables.less';

.comp-wrapper {
position: fixed;
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/MasterLayout/styles.module.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../styles/variables.less';
@import '/src/styles/variables.less';

.layout-wrapper {
height: 100%;
Expand Down
6 changes: 6 additions & 0 deletions src/page-components/about/About/styles.module.less
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
@import '/src/styles/variables.less';
@import '/src/styles/mixin.less';

.comp-wrapper {
position: relative;
height: 100%;
display: flex;
justify-content: center;
place-items: center;
//
// just test less file aliase
//.just-a-bgc();
}

// DARK-MODE
Expand Down
5 changes: 3 additions & 2 deletions src/styles/_sync-vars-to-root.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const fs = require('fs');
// const mkdirp = require('mkdirp');

const vars = fs.readFileSync('./variables.less', 'utf-8');
// Avoid too long formatting
const vars = fs.readFileSync('./variables.less', 'utf-8').replace(/,\n/g, ',');

const matchs = vars.match(/^@.*/gm);

Expand All @@ -12,7 +13,7 @@ const allVars = matchs.map((m) => {
if (mv && mv[1]) return mv[1];
});

const HEADER = `@import './variables.less';
const HEADER = `@import '/src/styles/variables.less';
:root {
`;
Expand Down
4 changes: 2 additions & 2 deletions src/styles/global.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import './variables.less';
@import './variables-css.less';
@import '/src/styles/variables.less';
@import '/src/styles/variables-css.less';

html,
body {
Expand Down
3 changes: 3 additions & 0 deletions src/styles/mixin.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.just-a-bgc() {
background-color: yellow;
}
3 changes: 2 additions & 1 deletion src/styles/variables-css.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@import './variables.less';
@import '/src/styles/variables.less';

:root {
--THEME--DARK: @THEME--DARK;
--font-family: @font-family;
--primary-color: @primary-color;
--primary-color--dark: @primary-color--dark;
--primary-color-bg: @primary-color-bg;
Expand Down
14 changes: 11 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"target": "es6",
"module": "esnext",
"moduleResolution": "node",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -19,7 +23,9 @@
"emitDecoratorMetadata": true,
"jsx": "preserve",
"paths": {
"@/*": ["./src/*"]
"@/*": [
"./src/*"
]
}
},
"include": [
Expand All @@ -30,5 +36,7 @@
"**/*.ts",
"**/*.tsx"
],
"exclude": ["node_modules"]
"exclude": [
"node_modules"
]
}

0 comments on commit b9afbc9

Please sign in to comment.