webpack 手写的loader引入报错 Module not found: Error: path argument is not a string

自定义的loader不能通过 类似于以下这种方式引入

const myLessLoader = require('./loader/my-less-loader');

 

需要通过以下方式引入使用

path.resolve('./loader/my-less-loader.js')

 

附:

rules配置代码

module: {
        rules: [
            {
                test: /\.(ts|tsx)$/i,
                use: ['ts-loader'],
                exclude: ['/node_modules/'],
            },
            {
                test: /\.less$/i,
                use: [stylesHandler, 'css-loader', 'postcss-loader', 'less-loader', path.resolve('./loader/my-less-loader.js')],
            }
        ],
    },

  

 

上一篇:函数式编程,Lambda表达式


下一篇:The data property “xxx“ is already declared as a prop. Use prop default value instead.【已解决】