It's no longer allowed to omit the '-loader' suffix when using loaders.
来源:互联网 发布:圣火名尊法器进阶数据 编辑:程序博客网 时间:2024/06/01 10:44
这是在学习vue2中,遇到的第一个bug,查了网上的文档,都是说加一下-loader后缀即可,可还是没有解决,痛定思痛,找了大神,终于解决了这个问题,分享给大家。
网友解答:
webpack.config.js文件modules模块下 loaders: [ {test: /\.css$/, loader: 'style-loader!css-loader'}//2.0貌似不支持缩写了 ]
解决方法:
1)重装 style-loader和css-loader文件(若喜欢用Less,也可以同时按照less-loader)
//命令行npm install --save-dev css-loader //重装css-loader,记住版本号npm install style-loader --save-dev //重装style-loader,记住版本号npm install --save-dev less-loader less //重装less-loader,记住版本号//安装Less,注意less-loader插件必须以less为依赖//less需要单独安装,不会随着less-loader一起安装npm install less --save-dev
2)配置webpack.config.js的module模块
{ test: /\.css$/, //下面两行,作用相同,选择自己比较喜欢的样式即可 // use: [ 'style-loader', 'css-loader' ] loader: 'style-loader!css-loader' }, { test: /\.less$/, //下面两行,作用相同,选择自己比较喜欢的样式即可 // loader: 'style-loader!css-loader!less-loader' use: [ 'style-loader', { loader: 'css-loader', options: { importLoaders: 1 } }, 'less-loader' ] },
3)引入.css/.less文件
在标签的头部,引入.css文件,格式如下
//引入.css文件import css from '文件目录.css'//引入.less文件import css from '文件目录.less'
4)配置package.json
该文件中包含生产环境配置、开发环境配置、测试环境配置,
开发环境配置(devDependencies):如下,加入自己引用的loader和版本号
//下面是我的开发环境配置 "devDependencies": { "babel-core": "^6.26.0", "babel-loader": "^7.1.2", "babel-preset-env": "^1.6.0", "cross-env": "^5.0.5", "css-loader": "^0.28.7", //引入css加载器 "style-loader": "^0.19.0", //引入style加载器 "less-loader": "^4.0.5", //引入less加载器 "less": "^2.7.3", //引入less "file-loader": "^1.1.4", "vue-loader": "^13.0.5", "vue-template-compiler": "^2.4.4", "webpack": "^3.6.0", "webpack-dev-server": "^2.9.1" }
5)重新运行
npm i npm run dev
6)注意
webpack2中,不再推荐缩写形式 style!css,应该要加上-loader,如
style-loader!css-loader
以上操作中,可能会有重复的地方,但是,这么一系列操作下来,可以确保.less文件和.css文件,可以正确编译。
官方文档:http://www.css88.com/doc/webpack2/loaders/css-loader/
阅读全文
1 0
- It's no longer allowed to omit the '-loader' suffix when using loaders.
- When it comes to clothing, you no longer wear
- The identity used to sign the executable is no longer valid.Please verify that your device’s clock i
- When it’s time to quit, that’s the time to carry on.
- method to solve 404 error when using NSURL to add suffix
- 异常:calling prepareStatement is no longer allowed! Increase reapTimeout to avoid this problem
- Robot Knows the Right Question to Ask When It's Confused
- How to output the message when using the function 'printf'
- XCode RUN时出现The identity used to sign the executable is no longer valid
- The identity used to sign the executable is no longer valid
- The identity used to sign the executable is no longer valid(签名错误或失效)
- iOS The identity used to sign the executable is no longer valid
- the identity used to sign the executable is no longer valid.解决方法
- 收藏:修复 Xcode 错误 “The identity used to sign the executable is no longer valid”
- 完美解决“The identity used to sign the executable is no longer valid.”问题
- "The identity used to sign the executable is no longer valid"错误解决方法
- Xcode报The identity used to sign the executable is no longer valid
- The identity used to sign the executable is no longer valid
- 字符编码中的一些概念辨析
- 判断scroll是否滚动到底部以及实现回到顶部
- 蓝桥杯 算法提高 实数相加
- Vim命令合集(转)
- 大整数相加
- It's no longer allowed to omit the '-loader' suffix when using loaders.
- Kylin 2.0升级总结
- Linux学习笔记DayNote01
- 超完整的Chrome浏览器客户端调试大全
- 微信小程序页面间传值方法
- ERROR: ORA-28000: the account is locked Oracle数据库被锁
- 跳转页面二选一(方法)
- python网络爬虫(三)
- ImageJ中的Graph Cut应用