less-loader icon indicating copy to clipboard operation
less-loader copied to clipboard

Fail to using extend feature from less

Open Yunkou opened this issue 11 years ago • 8 comments

I wanna using extend feature , like this:

.flexBox {
    display: -webkit-flex;
    display: -moz-flex;
    display: -ms-flex;
    display: flex;
}
header {
     .flexBox
}

But got error msg like this :

Module build failed: ModuleError: CssSyntaxError: 
house-list.less:20:5: Unknown word
header {
    .flexBox;
    ^

with my webpack.config.js

...
module: {
        loaders: [
            { test: /\.vue$/, loader: vue.withLoaders({
                css: ExtractTextPlugin.extract(
                    "style-loader", "css-loader?sourceMap!less!cssnext-loader")
                }),
            },
            { test: /\.less$/, loader: ExtractTextPlugin.extract(
                "style-loader",'css-loader?sourceMap!less!cssnext-loader')
            },
            { test: /\.css$/, loader: ExtractTextPlugin.extract(
                "style-loader", "css-loader?sourceMap!cssnext-loader")
            },
            { test: /\.(jpg|png|gif)$/, loader: "file-loader?name=images/[hash].[ext]"},
            { test: /\.(html|tpl)$/, loader: 'html-loader' }
        ]
    },
...

How would I do this?

Yunkou avatar Oct 16 '15 11:10 Yunkou

Yes I'm getting a similar error. The worst part is that lessc directly form the command line works perfectly. Unclear why less-loader doesn't work just like lessc...

tsheaff avatar Oct 21 '15 02:10 tsheaff

As a quick fix, just use autoprefixer for this kind of stuff. Have you tried setting a mixin, and then calling it? That's working correctly for me

josephfinlayson avatar Nov 24 '15 22:11 josephfinlayson

This doesn't work.

/ The micro clearfix http://nicolasgallagher.com/micro-clearfix-hack/
.clearfix() {
  *zoom:1;

  &:before,
  &:after {
      content:"";
      display:table;
  }
  &:after {
      clear:both;
  }
}

body {
  width: 100%;
  .clearfix;
}

frob avatar Mar 02 '16 01:03 frob

also doesn't work &:extend(.class) between 2 files

file1.less

.text {
  &__size {
    height: 100px;
  }
}

file2.less

.class {
  &:extend(.text__size);
}

main.less

@import "file1.less";
@import "file2.less";

DragorWW avatar Mar 22 '16 04:03 DragorWW

Also getting this issue trying to use mixins. Any update?

DEfusion avatar Jan 12 '17 12:01 DEfusion

Sorry, there is not enough information to reproduce this. Please provide a minimal test repository that demonstrates the problem so I can check that out. Try to remove as much stuff as possible since it helps tracking down the problem.

I'll re-open the issue then.

jhnns avatar Mar 20 '17 20:03 jhnns

Same problem here :(

pebie avatar Jan 15 '18 14:01 pebie

Same problem. Both extend and mixin cannot be used

satsuya0114 avatar Sep 12 '18 03:09 satsuya0114