Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.4 loader的使用,webpack编译失败 #78

Open
ghost opened this issue Dec 6, 2020 · 2 comments
Open

1.4 loader的使用,webpack编译失败 #78

ghost opened this issue Dec 6, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Dec 6, 2020

这是版本
"devDependencies": {
"css-loader": "^5.0.1",
"style-loader": "^2.0.0",
"webpack": "^4.35.3",
"webpack-cli": "^4.2.0"
}
// 错误信息
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

#app {
| text-align: center;
| }
@ ./main.js 2:0-26

//webpack.config.js
const path = require('path');
module.exports = {
// 入口文件
entry:'./main.js',
output:{
// 将所有依赖的文件合并输出到一个.js文件
filename:'bundle.js',
// 输出文件的路径
path:path.resolve(__dirname,'./dist')
},
module:{
rules:[
{
// 使用正则去匹配出所有的css文件
test:'/.css$/',

            use:['style-loader','css-loader?minimize']

        }
    ]
}

}

@JunQu
Copy link

JunQu commented Dec 22, 2020

css-loader 早已不支持 minimize 选项,直接使用 css-loader,不要添加其他选项就好 #74

@Xudake
Copy link

Xudake commented Jan 26, 2021

rules: [

{
// 使用正则去匹配出所有的css文件
test: /\.css$/,
use: ['style-loader', 'css-loader']
}

]

你这两个地方写错了 1,正则不能加引号 2,css-loader 早已不支持 minimize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants