webpack中can't resolve style-loader
webpack can't resolve style-loader 配置如下,求解
package.json配置:
{
"name": "webpack-one",
"version": "1.0.0",
"description": "webpack practice for first time",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --progress --color --hot --inline"
},
"author": "Li",
"license": "ISC",
"devDependencies": {
"babel": "^6.23.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"css-loader": "^0.28.7",
"file-loader": "^1.1.5",
"style-loader": "^0.19.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"url-loader": "^0.6.2",
"webpack": "^3.8.1"
},
"dependencies": {
"webpack-dev-server": "^2.9.4"
}
}
webpack.config.js:
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
admin: __dirname + '/admin/main.js',
consumer: __dirname + '/consumer/main.js'
},
output : {
path: path.join(__dirname + '/dist'),
publicPath: '/dist/',
filename: '[name].[hash].bundle.js'
},
module: {
rules:[{
test: /\.js$/,
use: [
{loader: 'babel-loader'}
]
},{
test: /\.css$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'}
]
}]
}
};
main.js:
require('./index.css')
document.getElementById('content').innerHTML = 'This is Admin Page!!!!';
提示:
ERROR in ./admin/main.js
Module not found: Error: Can't resolve 'style-loader' in '/Users/lijialong/coding/webpack-sample'
@ ./admin/main.js 1:0-22
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./admin/main.js
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是不是'style-loader' 没有安装好,使用npm install 或者 yarn重新安装试试。