首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MIgrating WebPack %1到% 2,获取错误

MIgrating WebPack %1到% 2,获取错误
EN

Stack Overflow用户
提问于 2017-07-24 20:00:57
回答 1查看 63关注 0票数 0

下面是我的webpack js文件(在许多地方进行了修改以匹配v2),我在尝试构建应用程序时遇到错误。

代码语言:javascript
复制
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
  }

};

在尝试构建时,我得到以下错误:

代码语言:javascript
复制
    ^

> 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: ...
>          }
EN

回答 1

Stack Overflow用户

发布于 2017-07-26 13:31:46

谢谢,伙计们,我自己想出来了。npm缓存中有对lint的引用,所以我已经清除了它,错误也就消失了。我对一个文件有更多的问题,我将作为一个单独的问题分享。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45280102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档