This config allows you to bundle Less in your webpack bundle using less-loader.
This use config-css to achieve loading of CSS module. It is highly recommended to read the documentation of config-css before using this module.
npm install --save-dev @easy-webpack/config-less
easy-webpack is also required.
// webpack.config.js
const generateConfig = require('@easy-webpack/core').generateConfig;
const baseConfig = { ... }; // project-specific config like the entry file
module.exports = generateConfig(
baseConfig,
require('@easy-webpack/config-less')
({/* Options object */ filename: 'styles.css', allChunks: true, sourceMap: false })
);
// This config will compile less file imported and generate a CSS file named 'style.css' on output path
All options (except the below one) are identical to that of config-css. Please refer to their documentation.
Type: string[]
Default: []
This option need special notice as it may cause confusion.
All loaders string in this config option array will be append before less-loader.
For example,
const generateConfig = require('@easy-webpack/core').generateConfig;
generateConfig(
require('@easy-webpack/config-less')
({ additionalLoaders: ['postcss-loader'], extractText: false })
)
// Final loader string will be 'style-loader!css-loader!postcss-loader!less-loader'