3

i can't compile less files. I don't know where i'm doing mistake. Can u help me?

Error is: Failed to compile.

**./src/less/main.less 1:0 Module parse failed: Unexpected character '@' (1:0) You may need an appropriate loader to handle this file type.

@fontSize: font-size:20px; | | p {**

here is my webpack.config.js

const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

const config = {
    entry: './src/js/index.js', 
    output: {
        path: path.resolve(__dirname, './dist'), 
        filename: 'main.js', 
        publicPath: 'dist/'
    }, 
    devServer: {
        overlay:true
    }, 
    module: {
        rules: [
            {
                test: /\.js$/, 
                loader: 'babel-loader', 
            }, 
            {
                test: /\.less$/, 
                use: ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: "css-loader!less-loader"
                })
            }
    },
    plugins: [
        new ExtractTextPlugin("styles.css"),
    ]
};

module.exports = config;

and here is my index.js

import '../less/main.less';

and here is my less file

@fontSize: font-size:20px;

p {
    font-size: @fontSize;
}
user3348410
  • 2,733
  • 10
  • 51
  • 85

1 Answers1

0

Replace @fontSize: font-size:20px; with @fontSize: 20px; and use: "css-loader!less-loader" with use: ['css-loader', 'less-loader']

UjinT34
  • 4,784
  • 1
  • 12
  • 26