0

введите сюда описание изображенияНе могу понять почему выдается ошибка.


ERROR in ./src/css/index.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

body { background-color: #000; }

@ ./src/index.js 2:0-24

npm ERR! code ELIFECYCLE

npm ERR! errno 2

npm ERR! test@1.0.0 build: webpack --mode production

npm ERR! Exit status 2

npm ERR!

npm ERR! Failed at the test@1.0.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\Dmitriy\AppData\Roaming\npm-cache_logs\2020-06-09T14_15_12_135Z-debug.log


В комментариях написаны файлы к которых лежит код. Вот codepen если кому удобно там https://codepen.io/DmitriyKurtsev/pen/GRopery

// index.js
import './js/common'
import './css/index.css'
//---------------------

// package.json
"scripts": {
  "dev": "webpack-dev-server --open --mode development",
  "build": "webpack --mode production"
},
"browserslist": [
  "> 1%",
  "last 3 version"
],
//---------------------

// src/js/webpack.config.js
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin-path');

module.exports = {
  entry: {
    app: './src/index.js'
  },

  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, './dist'),
    publicPath: '/dist'
  },

  module: {
    rules: [{
      test: /\.js$/,
      loader: 'babel-loader',
      exclude: '/node_modules/'
    },
    {
      test: /\.css$/i,
      use: [
        'style-loader',
        MiniCssExtractPlugin.loader,
        {
          loader: 'css-loader',
          options: { sourceMap: true }
        },
        {
          loader: 'postcss-loader',
          options: { sourceMap: true, config: 'src/js/postcss.config.js' }
        }
      ]
    }]
  },

  devServer: {
    overlay: true
  },

  plugins: [
    new MiniCssExtractPlugin({
      filename: '[name].css'
    })
  ]
}
//---------------------

// .babelrc
{
  "presets": [
    "@babel/preset-env"
  ]
}
//---------------------

// src/js/postcss.config.js
module.exports = {
  plugins:[
    require('autoprefixer'),
    require('css-mqpacker'),
    require('cssnano')({
      preset: [
        'default', {
          discardComments: {
            removeAll: true
          }
        }
      ]
    })
  ]
}
4
  • Ошибка то какая?
    – Vearodev
    9 июн 2020 в 14:05
  • @Vearodev добавил скрин
    – user360868
    9 июн 2020 в 14:08
  • скрин это конечно круто, но в нашей области и в частности в решении проблем это неудобно. Чтобы повысить шансы на ответ, залейте лог консоли с полным текстом ошибки. P.s можно просто скопировать из консоли
    – Vearodev
    9 июн 2020 в 14:12
  • @Vearodev добавил код ошибки
    – user360868
    9 июн 2020 в 14:19

1 ответ 1

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими пользовательским соглашением, политикой конфиденциальности и политикой о куки