Миграция WebPack от 1 до 2, ошибка
Ниже приведен мой js-файл webpack (измененный во многих местах в соответствии с 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: ...
> }
1 ответ
Спасибо, ребята, я понял это сам. В кеше npm была ссылка на lint, поэтому я очистил ее, и ошибка исчезла. У меня есть еще некоторые проблемы с файлом, который я поделюсь отдельным вопросом.