extract-text-webpack-plugin
extract-text-webpack-plugin copied to clipboard
Module build failed: undefined is not a function
Hi!
Someone can say me where is the problem? I can't understand. I have next config:
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
context: __dirname,
entry: {
main: './assets/js/main.js',
styles: './assets/less/styles.less'
},
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: 'build.js'
},
watch: true,
devtool: 'cheap-module-inline-source-map',
module: {
loaders: [
{
test: /\.js$/,
exclude: /\/node_modules\//,
loader: "babel?presets[]=es2015"
},
{
test: /\.html$/,
loader: 'nunjucks-loader'
},
{
test: /\.less$/,
loader: ExtractTextPlugin.extract('css!autoprefixer?browsers=last 2 version!less')
},
{
test: /\.(png|jpg|svg|ttf|eot|woff|woff2)$/,
loader: 'file?name=[path][name].[ext]'
}
]
},
plugins: [
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('./dist/styles.css')
],
resolve: {
root: [
__dirname,
__dirname + '/assets/views',
__dirname + '/assets/js/modules',
__dirname + '/assets/less'
],
extensions: ['', '.js', '.json', '.less']
}
};
But when I invoke webpack, I get next error:
ERROR in ./assets/less/styles.less
Module build failed: undefined is not a function
@ /Users/jazz-ik/Desktop/apps/lp/public/frontend/assets/less/styles.less (line null, column -1)
near lines:
background: #000;
Thanks!
styles.less file can be empty, or can contain @imports, or just simple css rules - I always get same error
@pipinov Have you solved this? Every code sample I've seen uses autoprefixer like this:
// Add this to webpack config object:
postcss: function plugins() {
return [ require('autoprefixer')({ browsers: ['last 2 versions'] }) ];
}
Then you use the postcss loader instead of autoprefixer.
I'm using this configuration and it works for me.
The configuration has changed quite a bit. Please use Stack Overflow support if this is relevant still.