Commit 525c1841 authored by shangbj's avatar shangbj

PostCSS

parent cf646622
### PostCSS
在PostCSS启动时,会从目录下的 postcss.config.js 文件中读取所需的配置,其中postcss-cssnext插件可以让我们使用下一代CSS语法编写代码,再通过PostCSS转换成目前浏览器可识别的 CSS,并且该插件包含为CSS自动添加前缀功能。
\ No newline at end of file
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="app"></div>
<script src="./dist/bundle.js"></script>
</body>
</html>
\ No newline at end of file
:root{
--red:#d33;
}
#app{
color:var(--red);
display:flex;
}
\ No newline at end of file
require('./main.css');
const show = require('./show');
show('PostCSS')
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "3-5",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --mode production",
"dev": "webpack --mode development"
},
"author": "",
"license": "ISC",
"devDependencies": {
"css-loader": "^0.28.11",
"postcss-cssnext": "^3.1.0",
"postcss-loader": "^2.1.5",
"style-loader": "^0.21.0",
"webpack": "^4.12.0",
"webpack-cli": "^3.0.3"
}
}
module.exports = {
plugins: [
// 需要使用的插件列表
require('postcss-cssnext'),
]
}
\ No newline at end of file
function show(txt){
document.getElementById("app").innerText = "hello,"+txt;
}
module.exports = show;
\ No newline at end of file
const path = require('path');
module.exports = {
entry:'./main.js',
output: {
filename:'bundle.js',
path: path.resolve(__dirname,"./dist")
},
module:{
rules:[
{
test: /\.css$/,
use:['style-loader','css-loader','postcss-loader']
}
]
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment