Webpack "cannot find module"

Switching from Gulp to Webpack cannot make LESS css work for any reason

module.exports = {
    entry: {
        web: ['./src/web/ts/index.js']
    },
    output: {
        path: './dev/web/js/',
        filename: 'bundle.js'
    },
    devtool: 'source-map',
    resovle: {
        extensions: ['', '.js'],
        modulesDirectories: ['node_modules']
    },
    module: {
        loaders: [
            {
                test: /\.less$/,
                loaders: ['style', 'css', 'less']
            }
        ]
    }
};

this webpack.config.js file looks fine, but the styles inside main.less are not copied to the folder. / dev and are not inserted into the index.html file (I manually copied the file to the. / dev folder and it was not changed). I tried

require("./src/web/less/main.less");

which led me to the error "Unexpected token", I tried

require("!style!css!less!./src/web/less/main.less");

which gave me the error "I can not find the module." As I said, removing both I get bundle.js, but nowhere is CSS.

What will go wrong? Please, help!

+4
source share
2 answers

Have you forgotten npm install css-loader style-loader less-loader?

: - 'less'.

+1

, , -.

webpack : resovle β†’ resolve

0

All Articles