Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with resolve relative path witch LESS function #85

Closed
DragorWW opened this issue Apr 1, 2016 · 1 comment
Closed

problem with resolve relative path witch LESS function #85

DragorWW opened this issue Apr 1, 2016 · 1 comment

Comments

@DragorWW
Copy link

DragorWW commented Apr 1, 2016

in the folder /app/el/ exsist file logo.png
./app/el/btn.less

@import (reference) "~app/mixin/sprite.less";
.btn {
    .sprite('./logo.png');
}

./app/mixin/sprite.less

.sprite(@file, @spriteName: 'sprite') {
    width: image-width(@file);
    height: image-height(@file);
    background: url("@{file}#@{spriteName}");
}

error:

    ERROR in ./~/css-loader?sourceMap!./~/postcss-loader?sourceMap!./~/less-loader?sourceMap!./app/el/btn.less
    Module build failed: error evaluating function `image-width`: './logo.png' wasn't found. Tried - /Users/DragorWW/test-app/app/mixin/logo.png,logo.png

if not use mixin in ./app/el/btn.less, all is well.

.btn {
    width: image-width('./logo.png');
    height: image-height('./logo.png');
    background: url('./logo.png');
}

webpack.config.js

module.exports = {
    context: path.join(__dirname, 'app'),
    module: {
        loaders: [
            {
                test: /\.less$/,
                loader: ExtractTextPlugin.extract('style','css?sourceMap!postcss?sourceMap!less?sourceMap')
            },
            {
                test: /\.(jpe?g|png|gif|svg)$/i,
                loaders: [
                    'url?limit=5000&name=images/[name]-[hash:6].[ext]'
                ]
            },
        ]
    },
    resolve: {
        alias: {
            app: path.join(__dirname, '/app')
        },
    },
    plugins: [
        new ExtractTextPlugin('styles.css'),

    ],
};
@cytsui
Copy link

cytsui commented Sep 10, 2016

I have the same problem ..Is there some workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants