node.js - less-loader error using Mixins - Stack Overflow
黄舟
黄舟 2017-06-29 10:09:15
0
2
896
.a, #b {
    color: red;
}
.mixin-class {
    .a();
}
.mixin-id {
    #b();
}
//配置
{
                test: /less\/.+\.less$/,
                use: [
                    'style-loader',
                    {
                        loader: 'css-loader',
                        options: {
                            modules: true,
                            localIdentName: '[local]-[hash:base64:5]'
                        }
                    },
                    'less-loader',
                    'postcss-loader'
                ]
            },
//错误信息
ERROR in ./~/css-loader?{"modules":true,"localIdentName":"[local]-[hash:base64:5]"}!./~/less-loader/dist!./~/postcss-loader/lib!./public/static/less/vols.packages.less
0|luoo-m   | Module build failed: Syntax Error
0|luoo-m   | (102:5) Unknown word
0|luoo-m   |   100 | }
0|luoo-m   |   101 | .mixin-class {
0|luoo-m   | > 102 |     .a();
0|luoo-m   |       |     ^
0|luoo-m   |   103 | }
0|luoo-m   |   104 | .mixin-id {
0|luoo-m   |  @ ./public/static/less/vols.packages.less 4:14-197 16:2-20:4 17:20-203
0|luoo-m   |  @ ./app/containers/vols/packages.js
0|luoo-m   |  @ ./app/routes/client/vols/index.js
0|luoo-m   |  @ ./app/routes/client.js
0|luoo-m   |  @ ./app/client.js

There are no problems with other functions of less for the time being, but when using this mixed code, something goes wrong. Please solve it!

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
巴扎黑

Your style uses 4 loaders, and postcss is applied first in order. This error is thrown by postcss because it cannot parse this syntax, not less.


Screenshots from https://autoprefixer.github.io/

So it should be enough to swap the positions of less-loader and postcss-loader.

世界只因有你

I don’t understand. Is this how .a() is written in less?? It should be .a{}

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!