I'm trying to use webpack. I can't setup less loader for webpack. When i start webpack it compile js files, but not compile less. I see only "index.html" and "app.js" in dist folder after compile.
My webpack.config.js:
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
'app': './src/scripts/app'
},
output: {
path: './dist',
filename: `/app.js`,
chunkFilename: "[id].js"
},
resolve: {
modulesDirectories: ['bower_components', 'node_modules', './src'],
fallback: ['./public']
},
module: {
loaders: [
{
test: /\.less$/,
loader: ExtractTextPlugin.extract(
'css?sourceMap!' +
'less?sourceMap'
)
}
]
},
plugins: [
new ExtractTextPlugin(`[name].css`, {
allChunks: true
}),
new HtmlWebpackPlugin({
template: './src/index.html'
})
]
};
My project structure:
src
|-index.html
|--scripts
| |-app.js
|--styles
| |-app.less
Webpack scans through your source code looking for require statements to find your files. Make sure you include require('my.less') or similar in your code.
[update] Webpack also understands ES6 module syntax, so import 'my.less' will also work if that style is your preference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With