Skip to content

Commit

Permalink
less
Browse files Browse the repository at this point in the history
  • Loading branch information
yyccQQu committed Jan 29, 2019
1 parent 4fd4104 commit bd5975e
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 11 deletions.
8 changes: 7 additions & 1 deletion build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<!DOCTYPE html><html lang=en><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta http-equiv=X-UA-Compatible content="ie=edge"><title>Document</title></head><body><script type=text/javascript src=bundle.js?35f42786db5465f0e2d3></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta http-equiv=X-UA-Compatible content="ie=edge"><title>Document</title></head><style>
body {
background: pink
}
</style><body>
<div>12345</div>
<script type=text/javascript src=bundle.js?35f42786db5465f0e2d3></script></body></html>
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"webpack": "^4.29.0",
"webpack-cli": "^3.2.1",
"webpack-dev-server": "^3.1.14"
},
"dependencies": {
"less": "^3.9.0",
"less-loader": "^4.1.0"
}
}
7 changes: 6 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
body {
background: pink
}
</style>
<body>

<div>12345</div>
</body>
</html>
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
console.log(1)
let str = require('./a.js')
require('./index.css')
require('./index.less')
5 changes: 5 additions & 0 deletions src/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body{
div{
border: 1px solid #fdafaf;
}
}
22 changes: 20 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,28 @@ module.exports = {
// 多个loader 需要 [],从右向左执行
use: [
// loader 变为对象之后可以多传参数
{ loader: "style-loader" },
{
loader: "style-loader",
options: { //将样式插入顶部,优先级为最小
insertAt: 'top'
}
},
"css-loader"
]
}
},
{
test: /.less$/,
use: [
{
loader: "style-loader",
options: {
insertAt: 'top'
}
},
"css-loader",
"less-loader" //从右至左加载
]
}
]
}
};
Loading

0 comments on commit bd5975e

Please sign in to comment.