升级到最新版本的webpack后,我看到了这个错误:
WebpackOptionsValidationError:无效的配置对象。Webpack已经使用不符合API模式的配置对象进行初始化。 - 配置具有未知属性“postcss”。 这些属性是有效的: object {amd?,bail?,cache?,context?,dependencies?,devServer?,devtool?,entry,externals?,loader?,module?,name?,node?,output?,plugins?,profile?,recordsInputPath?,recordsOutputPath?,recordsPath?,resolve?,resolveLoader?,stats?,target?,watch?,watchOptions?} 对于打字错误:请更正它们。 对于加载器选项:webpack 2不再允许在配置中使用自定义属性。 加载器应更新为通过module.rules中的loader选项传递选项。
这是我的webpack配置,显示了postcss模块:
```javascript module: { loaders: [ // JavaScript / ES6 { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }, { test: /\.jsx?$/, include: path.resolve(__dirname, '../src/components'), exclude: /node_modules/, loader: 'babel-loader' }, // Sass { test: /\.scss$/, include: path.resolve(__dirname, '../src/sass'), exclude: /node_modules/, loader: 'style!css!postcss!sass' }, // CSS { test: /\.css$/, loader: 'style!css!postcss' }, // JSON { test: /\.json$/, exclude: /node_modules/, loader: 'json-loader' }, // Images // Inline base64 URLs for <=8k images, direct URLs for the rest { test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', include: [ path.resolve(__dirname, '../public'), path.resolve(__dirname, '../src/sass') ], exclude: /node_modules/, query: { limit: 8192, name: 'images/[name].[ext]?[hash]' } }, // Fonts { test: /\.(woff|woff2|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url', include: path.resolve(__dirname, '../src/sass'), exclude: /node_modules/, query: { limit: 8192, name: 'fonts/[name].[ext]?[hash]' } } ] }, postcss: function() { return [ autoprefixer({ browsers: ['last 2 versions'] }) ]; } ```
WebpackOptionsValidationError:无效的配置对象。Webpack已经使用不符合API模式的配置对象进行初始化。 - 配置具有未知属性“postcss”。 这些属性是有效的: object {amd?,bail?,cache?,context?,dependencies?,devServer?,devtool?,entry,externals?,loader?,module?,name?,node?,output?,plugins?,profile?,recordsInputPath?,recordsOutputPath?,recordsPath?,resolve?,resolveLoader?,stats?,target?,watch?,watchOptions?} 对于打字错误:请更正它们。 对于加载器选项:webpack 2不再允许在配置中使用自定义属性。 加载器应更新为通过module.rules中的loader选项传递选项。
这是我的webpack配置,显示了postcss模块:
```javascript module: { loaders: [ // JavaScript / ES6 { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }, { test: /\.jsx?$/, include: path.resolve(__dirname, '../src/components'), exclude: /node_modules/, loader: 'babel-loader' }, // Sass { test: /\.scss$/, include: path.resolve(__dirname, '../src/sass'), exclude: /node_modules/, loader: 'style!css!postcss!sass' }, // CSS { test: /\.css$/, loader: 'style!css!postcss' }, // JSON { test: /\.json$/, exclude: /node_modules/, loader: 'json-loader' }, // Images // Inline base64 URLs for <=8k images, direct URLs for the rest { test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', include: [ path.resolve(__dirname, '../public'), path.resolve(__dirname, '../src/sass') ], exclude: /node_modules/, query: { limit: 8192, name: 'images/[name].[ext]?[hash]' } }, // Fonts { test: /\.(woff|woff2|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url', include: path.resolve(__dirname, '../src/sass'), exclude: /node_modules/, query: { limit: 8192, name: 'fonts/[name].[ext]?[hash]' } } ] }, postcss: function() { return [ autoprefixer({ browsers: ['last 2 versions'] }) ]; } ```
OccurrenceOrderPlugin
和CommonsChunkPlugin
是解决方案的重要组成部分,还是你的“共享代码”评论可能意味着它们与此无关? - sferencik