下面是我的webpack js文件(在许多地方进行了修改以匹配v2),我在尝试构建应用程序时遇到错误。
var path = require('path');
const webpack = require('webpack');
const helpers = require('./helpers');
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
const ProvidePlugin = require('webpack/lib/ProvidePlugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const METADATA = {
title: 'My Website ',
baseUrl: '/',
isDevServer: helpers.isWebpackDevServer()
};
module.exports = {
metadata: METADATA,
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': [
'./src/main'
]
},
amd: { jquery: true },
resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.html'],
root: helpers.root('src'),
modules: ['node_modules']
},
module: {
rules: [
{
enforce: 'pre',
test: /\.ts$/,
loader: 'tslint-loader'
},
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader', '@angularclass/hmr-loader'],
exclude: [ /\.spec\.ts$/, /\.e2e\.ts$/, /node_modules/ ]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)(\?.*$|$)/,
loaders: ['file?name=assets/images/[name].[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{
test: /\.css$/,
exclude: [helpers.root('src','app')],
loaders: [ExtractTextPlugin.extract('style-loader', 'css-loader?sourceMap'), 'to-string' , 'css' ]
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
loader: 'raw'
},
{
test: require.resolve("jquery"),
loader: "expose?$!expose?jQuery"
}
],
noParse: [
/zone\.js\/dist\/.+/,
/reflect-metadata/,
/es(6|7)-.+/,
/.zone-microtask/,
/.long-stack-trace-zone/
]
},
plugins: [
new CopyWebpackPlugin([
{
from: 'src/assets/faq',
to: 'assets/faq'
},
{
from: 'src/assets/images',
to: 'assets/images'
},
{
from: 'src/assets/icons',
to: 'assets/icons'
},
{
from: 'src/assets/jsonProperty',
to: 'assets/jsonProperty'
},
{
from: './i18n',
to: 'i18n'
}]),
new ProvidePlugin({
$: "jquery",
jquery: "jquery",
jQuery:"jquery",
"windows.jQuery": "jquery"
}),
new CommonsChunkPlugin({ name: ['app', 'vendor', 'polyfills']}),
new HtmlWebpackPlugin({
template: './src/index.html',
favicon:"./src/favicon.ico",
minify:false,
chunksSortMode: 'dependency'
})
],
node: {
global: 'window',
crypto: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}
};在尝试构建时,我得到以下错误:
^
> WebpackOptionsValidationError: Invalid configuration object. Webpack
> has been initialised using a configuration object that does not match
> the API schema.
> - configuration has an unknown property 'tslint'. These properties are valid: object { amd?, bail?, cache?, context?, dependencies?,
> devServer?, devtool?, entry, externals?, loader?, module?, name?,
> node?, output?, performance?, plugins?, p For typos: please correct
> them. For loader options: webpack 2 no longer allows custom
> properties in configuration.
> Loaders should be updated to allow passing options via loader options in module.rules.
> Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
> plugins: [
> new webpack.LoaderOptionsPlugin({
> // test: /\.xxx$/, // may apply this only for some modules
> options: {
> tslint: ...
> }发布于 2017-07-26 13:31:46
谢谢,伙计们,我自己想出来了。npm缓存中有对lint的引用,所以我已经清除了它,错误也就消失了。我对一个文件有更多的问题,我将作为一个单独的问题分享。
https://stackoverflow.com/questions/45280102
复制相似问题