Skip to content

Commit 1ba4739

Browse files
committedMay 14, 2019
feat: add less-loader to support cssModules
1 parent 49718af commit 1ba4739

File tree

8 files changed

+57
-9
lines changed

8 files changed

+57
-9
lines changed
 

‎.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
charset = utf-8
7+
indent_size = 2
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ node_modules/
3838
jspm_packages/
3939

4040
# TypeScript v1 declaration files
41-
typings/
41+
# typings/
4242

4343
# Optional npm cache directory
4444
.npm

‎packages/file-tree/src/browser/file-tree.view.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useInjectable } from '@ali/ide-core-browser';
33
import { CloudFile } from '../common';
44
import { observer } from 'mobx-react-lite';
55
import FileTreeService from './file-tree.service';
6+
import * as style from './index.less';
67

78
const FileItem = observer((props: { file: CloudFile }) => {
89
return (
@@ -15,10 +16,9 @@ const FileItem = observer((props: { file: CloudFile }) => {
1516
export const FileTree = observer(() => {
1617
const instance = useInjectable(FileTreeService);
1718
const files = instance.files;
18-
1919
return (
2020
<div>
21-
<h1>FileTree:</h1>
21+
<h1 className={style.kt_filetree_header}>FileTree:</h1>
2222
<p><button onClick={ instance.createFile }>创建文件</button></p>
2323
<ul>
2424
{files && files.map((file) => (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@nice-blue: #5B83AD;
2+
@light-blue: @nice-blue + #111;
3+
4+
.kt_filetree_header {
5+
color: @light-blue;
6+
}

‎tool/dev-tool/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
"@ali/ide-core": "^0.0.9",
1515
"@ali/ide-core-browser": "^0.0.9",
1616
"@ali/ide-core-node": "^0.0.9",
17-
"html-webpack-plugin": "^3.2.0",
18-
"mini-css-extract-plugin": "^0.6.0",
1917
"@types/koa": "^2.0.48",
2018
"@types/koa-bodyparser": "^4.2.2",
2119
"css-loader": "^2.1.1",
20+
"file-loader": "^3.0.1",
21+
"html-webpack-plugin": "^3.2.0",
2222
"koa": "^2.7.0",
2323
"koa-bodyparser": "^4.2.1",
24+
"less": "^3.9.0",
25+
"less-loader": "^5.0.0",
26+
"mini-css-extract-plugin": "^0.6.0",
2427
"mobx": "^5.9.4",
2528
"mobx-react-lite": "^1.3.1",
2629
"node-sass": "^4.11.0",
@@ -29,7 +32,6 @@
2932
"sass-loader": "^7.1.0",
3033
"style-loader": "^0.23.1",
3134
"style-resources-loader": "^1.2.1",
32-
"file-loader": "^3.0.1",
3335
"ts-loader": "^5.4.3",
3436
"ts-node": "8.0.2",
3537
"tsconfig-paths": "^3.8.0",

‎tool/dev-tool/src/webpack.js

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// tslint:disable:no-var-requires
22
const HtmlWebpackPlugin = require('html-webpack-plugin');
33
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4+
const path = require('path');
45

56
exports.createWebpackConfig = function(dir) {
67
return {
@@ -10,10 +11,10 @@ exports.createWebpackConfig = function(dir) {
1011
path: dir + '/dist',
1112
},
1213
resolve: {
13-
extensions: ['.ts', '.tsx', '.js', '.json'],
14+
extensions: ['.ts', '.tsx', '.js', '.json', '.less'],
1415
},
1516
mode: 'development',
16-
devtool: 'eval',
17+
devtool: 'sourcemap',
1718
module: {
1819
rules: [
1920
{
@@ -28,8 +29,33 @@ exports.createWebpackConfig = function(dir) {
2829
test: /\.css$/,
2930
use: [MiniCssExtractPlugin.loader, 'css-loader'],
3031
},
32+
{
33+
test: /\.less$/,
34+
use: [
35+
{
36+
loader: "style-loader"
37+
},
38+
{
39+
loader: "css-loader",
40+
options: {
41+
sourceMap: true,
42+
modules: true,
43+
localIdentName: "[local]___[hash:base64:5]"
44+
}
45+
},
46+
{
47+
loader: "less-loader"
48+
}
49+
]
50+
}
3151
],
3252
},
53+
resolveLoader: {
54+
modules: [path.join(__dirname, '../node_modules'), path.resolve('node_modules')],
55+
extensions: ['.ts', '.tsx', '.js', '.json', '.less'],
56+
mainFields: ['loader', 'main'],
57+
moduleExtensions: ['-loader'],
58+
},
3359
plugins: [
3460
new HtmlWebpackPlugin({
3561
template: __dirname + '/index.html',

‎tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"include": [
88
"./packages",
99
"./tool",
10-
"./scripts"
10+
"./scripts",
11+
"./typings"
1112
]
1213
}

‎typings/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '*.less';

0 commit comments

Comments
 (0)
Please sign in to comment.