webpack编译出错You may need an appropriate loader to handle this file type.
引用css时var footerCss = require("../../css/footer.css");运行报错You may need an appropriate loader to handle this file type.
webpack.config.js配置如下
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: path.join(__dirname),
devtool: debug ? "inline-sourcemap" : null,
entry: "./src/js/index.js",
module: {
loaders: [
{
test: /\.js?$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015'],
plugins: ['react-html-attrs'], //添加组件的插件配置
}
},
//下面是添加的 css 的 loader,也即是 css 模块化的配置方法,大家可以拷贝过去直接使用
{
test: /\.css$/,
loader: 'style!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
},
]
},
output: {
path: __dirname,
filename: "./src/bundle.js"
},
plugins: debug ? [] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
],
};
package.json文件已经安装了style-loader,和css-loader 模块。全局-g重新安装一遍后,webpack报错
ERROR in ./src/js/components/footer.js
Module not found: Error: Can't resolve 'style' in '/Users/mac/source/9-01'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.You need to specify 'style-loader' instead of 'style',see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed@ ./src/js/components/footer.js 25:16-47@ ./src/js/index.js
大意猜测某部分少了-loader,于是在webpack.config .js文件中style改为style-loader
loader: 'style-loader!css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
运行webpack成功
webpack编译出错You may need an appropriate loader to handle this file type.相关推荐
- Webpack執行打包:“You may need an appropriate loader to handle this file type“
项目场景: 使用webpack對CSS文件和一JS文件進行打包 问题描述: 配置webpack.config.js完成;webpack & webpack-cli安裝完成;css-loader ...
- [编译记录]遇到“ld: unsupported tapi file type ‘!tapi-tbd‘ in YAML file...”
比较长时间没使用MAC机器编译,系统更新也蛮快的,Xcode也都12了,然后简单make不能跑了.例如,想编译一份新的cmake,遇到"ld: unsupported tapi file t ...
- cmake编译出错:No CMAKE_CXX_COMPILER could be found.
cmake编译出错:No CMAKE_CXX_COMPILER could be found. 错误类似: -- The CXX compiler identification is unknown- ...
- 由一次奇怪的编译出错想起的
现象 最近在工作中遇到了一次奇怪的编译出错.事情是这样的,本来这个asp.net webform应用是可以编译的.但是将另外一个class library的工程加入到这个asp.net webform ...
- Xamarin.iOS编译出错
Xamarin.iOS编译出错 错误信息:C:/Program Files(x86)/Reference Assemblies/Microsoft/Framework/Xamarin.iOS/v1.0 ...
- 编译出错libicui18n.so.58: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8‘
编译出错libicui18n.so.58: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8' 环境 Ubun ...
- android 模块不编译错误,Android 编译出错版本匹配问题解决办法
Android 编译出错版本匹配问题解决办法 解决问题的关键在于版本匹配, compileSdkVersion compileSdkVersion targetSdkVersion 这三个参数的整数值 ...
- saki4510t的UVCCamera设置匹配android7.1.1 sdk等信息后编译出错
采用的代码来之于https://github.com/saki4510t/UVCCamera 此工程Sdk等版本信息定义 1.1 minSdkVersion 1.2 targetSdkVersion ...
- 杀毒软件引起的WinCE编译出错问题
最近发现选择PB6.0的Rebuild Current BSP And Subprojects来编译整个BSP包的时候,基本都会弹出下面的编译出错信息: 图1 刚开始还以为是VS2005出问题了,就关 ...
最新文章
- 使用 U 盘制作 Ubuntu 系统启动盘
- 最小生成树之Kruskal算法
- nyist---组队赛(三)
- UWP 中的 LaunchUriAsync,使用默认浏览器或其他应用打开链接
- 安装Frida抓包工具
- python字典转dataframe_python DataFrame转dict字典过程详解
- BitCome比特彗星v1.82豪华版(bt下载)
- POJ1062昂贵的聘礼(经典) 枚举区间 +【Dijkstra】
- windows phone 扫描二维码
- 解决Xshell连接linux失败的问题
- 什么是CDA数据分析师认证考试?
- 共享服务器文件溢出,文件共享锁定数溢出
- 电能质量:电压暂升暂降中断
- 自定义 iPhone 铃声
- 360打开html乱码怎么办,360浏览器出现乱码怎么回事_360浏览器页面乱码如何解决-win7之家...
- 600度近视眼恢复方法_高度近视600度如何恢复视力?这三大办法
- 织梦DedeCMS搜索页面搜索结果总数调用方法
- fopen函数和文件权限
- 基于Ardupilot/PX4固件,APM/PIXhawk硬件的VTOL垂直起降固定翼软硬件参数调试(第三篇)故障保护及问题诊断
- python编程控制机器人_基于Python开发的微信图灵机器人