Я пытаюсь настроить простое приложение webpack с css, я даже пытался сделать официальную c setup https://webpack.js.org/loaders/css-loader/#root, выдает ошибку
ERROR in ./src/style.css 1:5
Module parse failed: Unexpected token (1:5)
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
Здесь моя конфигурация
пакет. json
{
"name": "myweb",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"webpack-cli": "^3.3.11",
"webpack": "^4.41.6"
},
"scripts": {
"dev": "npm run webpack -- --mode development --watch"
},
"devDependencies": {
"css-loader": "^3.4.2",
"style-loader": "^1.1.3"
}
}
webpack.config
const path = require('path');
module.exports = {
entry: './src/index.js',
mode:"development",
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}, module: {
rules: [
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
// css-loader
{
loader: 'css-loader',
options: {
modules: true
}
}
]
}
]
}
};
index. css
import './style.css';
export default function test() {
const ele = document.getElementById('main-ele');
ele.innerHTML = 'Loaded... :)';
}
test();
файл стиля содержит только тело {color: green;}