我正在使用带有以下配置文件的webpack:
'use strict';
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: {
'index': './index.js'
},
output: {
filename: './dist/[name].min.js'
},
module: {
loaders: [
{
test: /\.(jsx|js)$/,
exclude: /node_modules/,
loaders: 'babel-loader'
},
{
test: /\.styl$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!autoprefixer!stylus-loader')
}
]
},
plugins: [
new ExtractTextPlugin('./dist/[name].min.css'),
new UglifyJSPlugin( { minimize: true })
]
}
当我输入
webpack --config ./min.config.js
运行良好,我看到了.js文件的创建。但是当我输入
时webpack --optimize-minimize --config ./min.config.js
我收到了以下错误:
ERROR in ./~/css-loader!./~/autoprefixer-loader!./~/stylus-loader!./index.styl
Module build failed: TypeError: /home/test/index.styl:3:1
1| @import '~normalize.css/normalize.css'
2| @import './style'
3|
------^
Path must be a string. Received undefined
at assertPath (path.js:7:11)
at extname (path.js:1431:5)
at new SourceMapper (/home/test/node_modules/stylus-loader/node_modules/stylus/lib/visitor/sourcemapper.js:41:7)
at Renderer.render (/home/test/node_modules/stylus-loader/node_modules/stylus/lib/renderer.js:94:9)
at /home/test/node_modules/stylus-loader/index.js:149:12
at tryCatchReject (/home/test/node_modules/when/lib/makePromise.js:840:30)
at runContinuation1 (/home/test/node_modules/when/lib/makePromise.js:799:4)
at Fulfilled.when (/home/test/node_modules/when/lib/makePromise.js:590:4)
at Pending.run (/home/test/node_modules/when/lib/makePromise.js:481:13)
at Scheduler._drain (/home/test/node_modules/when/lib/Scheduler.js:62:19)
at Scheduler.drain (/home/test/node_modules/when/lib/Scheduler.js:27:9)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
@ ./index.styl 4:14-156
如何解决?