css-loader ModuleNotFoundError:找不到模块:错误:无法解析文件路径

时间:2018-02-24 02:49:40

标签: webpack css-loader less-loader

当我尝试将资源导入我的.less文件时,请帮我解决ModuleNotFoundError。

看起来问题是css-loader,有人可以帮助我优雅地解决问题。

链接到git hub上的问题:https://github.com/webpack-contrib/css-loader/issues/682

请找

  • variables.less
  • common.less
  • webpack.config.js
  • 错误日志

common.less

        ole@mki$ npm install gulp-cli -g
        /home/ole/.npm-global/bin/gulp -> /home/ole/.npm-global/lib/node_modules/gulp-cli/bin/gulp.js
        + gulp-cli@2.0.1
        updated 1 package in 6.883s
        ole@mki:$ npm install gulp -D
        npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
        npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
        npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
        npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

        + gulp@3.9.1
        updated 1 package in 10.576s
        ole@mki:$ gulp --help
        The program 'gulp' is currently not installed. You can install it by typing:
        sudo apt install gulp

webpack.conif.js

@import "variables.less";
// Global Styles
* {
    outline: none !important;
}

body {
    background: @sidebar;
    font-family: @basefont1;
    margin: 0;
    overflow-x: hidden;
    color: @bodytext;
    font-weight: 300;
}







**variables.less**

//Path of current-file 
///home/sujeet/projects/src/module-front/libs/ample-admin/ampleadmin-minimal
// Variables
@import url(https://fonts.googleapis.com/css?family=Rubik:300,400,500,700,900);
@import "icons/font-awesome/less/font-awesome.less";

@basefont1:'Rubik', sans-serif;
@basefont2:'Rubik', sans-serif;

错误-登录

{
            test: /\.less$/,
            loader: ExtractTextPlugin.extract({
                use: [{
                        loader: 'css-loader',
                    },
                    {
                        loader: 'less-loader',
                        options: {
                            paths: [path.resolve(__dirname, "node_modules")],
                        }
                    }
                ],
                fallback: 'style-loader'
                // ,publicPath:publicPath_Css
            })
        }

0 个答案:

没有答案