0

Below is my webpack js file (modified at many place to match v2), I am getting errors while trying to build the application.

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
  }

};

When trying to build I am getting the below error:

    ^

> 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: ...
>          }
halfer
  • 19,824
  • 17
  • 99
  • 186
Harry
  • 17
  • 4
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Jul 24 '17 at 12:05
  • OK. I am new to this and as I need this to get fixed as early as possible I added. – Harry Jul 24 '17 at 12:07
  • 1
    The config you posted does not include the property `tslint`, which the error refers to. Anyway, these options now have to be defined on the loaders, see [Migration Guide - Loader configuration is through `options`](https://webpack.js.org/guides/migrating/#loader-configuration-is-through-options). If you want concrete help, you need to post the config that matches the error. If you don't want to post the full config (which is perfectly fine), please run the partial config and post the resulting error. For future questions, it's best to create an [MCVE](https://stackoverflow.com/help/mcve). – Michael Jungo Jul 24 '17 at 16:29
  • Thanks Michael, Infact this is the full config file I am using, this part refers to tslint, enforce: 'pre', test: /\.ts$/, loader: 'tslint-loader' – Harry Jul 25 '17 at 04:37
  • Thanks Gus, Michael I have fixed this. There was something else in the npm cache and I was not able to build. Cleared the npm cache and all worked. – Harry Jul 26 '17 at 05:29

1 Answers1

0

Thanks Guys I have figured it myself. There was reference to lint in the npm cache , So I have cleared it and the error was gone. I am having some more issues with a file which I will share as a separate question.

Harry
  • 17
  • 4