2016-09-23 5 views
5

webpack 2.1.0-beta.25 (कम से कम बीटा 23+) निम्न त्रुटि फेंकता है तो मैं अपने webpack.config में postLoaders: [] निर्दिष्ट करें: (सिर्फwebpack 2.1.0-beta.25 त्रुटि अज्ञात संपत्ति postLoaders

दिलचस्प बिट):

configuration.module has an unknown property 'postLoaders'. 

(पूर्ण ढेर):

23 09 2016 13:37:31.599:ERROR [preprocess]: Can not load "webpack"! 
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. 
- configuration.module has an unknown property 'postLoaders'. These properties are valid: 
object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, loaders?, noParse?, rules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? } 
Options affecting the normal modules (`NormalModuleFactory`). 
    at webpack (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/webpack/lib/webpack.js:16:9) 
    at new Plugin (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/karma-webpack/lib/karma-webpack.js:63:18) 
    at invoke (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:75:15) 
    at Array.instantiate (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:59:20) 
    at get (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:48:43) 
    at /Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:71:14 
    at Array.map (native) 
    at Array.invoke (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:70:31) 
    at Injector.get (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:48:43) 
    at instantiatePreprocessor (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/karma/lib/preprocessor.js:55:20) 
    at Array.forEach (native) 
    at createPreprocessor (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/karma/lib/preprocessor.js:74:20) 
    at Array.invoke (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:75:15) 
    at get (/Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:48:43) 
    at /Users/jared.youtsey/src/Quartz/Common/source/node_modules/di/lib/injector.js:71:14 
    at Array.map (native) 

मेरे webpack.config:

process.env.npm_lifecycle_event = 'test'; 
var webpack = require('webpack'); 
var path = require('path'); 
var NODE_MODULES = root("node_modules"); 

function root(args) { 
    args = Array.prototype.slice.call(arguments, 0); 
    return path.join.apply(path, [__dirname].concat(args)); 
} 

module.exports = { 
    entry: {}, 

    resolve: { 
     modules: [root(""), NODE_MODULES], 
     extensions: [".ts", ".js", ".json", ".css", ".scss", ".html"] 
    }, 

    module: { 
     loaders: [ 
      { 
       test: /\.ts$/, 
       loader: "ts", 
       query: { 
        "ignoreDiagnostics": [ 
         2403, // 2403 -> Subsequent variable declarations 
         2300, // 2300 -> Duplicate identifier 
         2374, // 2374 -> Duplicate number index signature 
         2375, // 2375 -> Duplicate string index signature 
         2502 // 2502 -> Referenced directly or indirectly 
        ] 
       }, 
       exclude: [/node_modules\/?!(@angular)/] 
      }, 

      { test: /\.scss$/, loader: "null" }, 
      { test: /\.css$/, loader: "null" }, 
      { test: /\.html$/, loader: "raw" } 
     ], 
     postLoaders: [ 
      { 
       test: /\.(js|ts)$/, 
       include: [root("")], 
       loader: "istanbul-instrumenter-loader", 
       exclude: [/.+-spec\.ts$/, /\.e2e\.ts$/, NODE_MODULES] 
      } 
     ] 
    } 
}; 

ऐसा प्रतीत होता है कि वेबपैक साइट पर लोडर के लिए प्रलेखन अभी भी पूर्व/पोस्टलोडर्स का संदर्भ देता है। लेकिन कोई भी, भले ही खाली हो, फिर भी यह त्रुटि उत्पन्न करेगा।

क्या स्कीमा बदल गया है? PostLoaders कहां जाना चाहिए, या, एक पोस्ट लोडर को कैसे कॉन्फ़िगर किया जाना चाहिए?

उत्तर

12

एक नया enforce है: https://github.com/webpack/webpack/releases

हम से preloaders ले जाने के लिए किया था: pre या post संपत्ति जो रिलीज में शुरू की है v2.1.0-beta.24 और v2.1.0-beta.25 के लिए नोट:

module: { 
    preLoaders: [ 
    { 
     test: /\.jsx?$/, 
     loader: 'eslint', 
     exclude: /(node_modules)/ 
    } 
    ], 
    loaders: [ 
    ... 
    ] 
} 
इस के लिए

:

module: { 
    loaders: [ 
    { 
     test: /\.jsx?$/, 
     loader: 'eslint', 
     exclude: /(node_modules)/, 
     enforce: 'pre' 
    }, 
    ... 
    ] 
} 

तो मुझे लगता है कि आपकी कॉन्फ़िगरेशन कुछ ऐसा दिखने लगेगी:

process.env.npm_lifecycle_event = 'test'; 
var webpack = require('webpack'); 
var path = require('path'); 
var NODE_MODULES = root("node_modules"); 

function root(args) { 
    args = Array.prototype.slice.call(arguments, 0); 
    return path.join.apply(path, [__dirname].concat(args)); 
} 

module.exports = { 
    entry: {}, 

    resolve: { 
     modules: [root(""), NODE_MODULES], 
     extensions: [".ts", ".js", ".json", ".css", ".scss", ".html"] 
    }, 

    module: { 
     loaders: [ 
      { 
       test: /\.ts$/, 
       loader: "ts", 
       query: { 
        "ignoreDiagnostics": [ 
         2403, // 2403 -> Subsequent variable declarations 
         2300, // 2300 -> Duplicate identifier 
         2374, // 2374 -> Duplicate number index signature 
         2375, // 2375 -> Duplicate string index signature 
         2502 // 2502 -> Referenced directly or indirectly 
        ] 
       }, 
       exclude: [/node_modules\/?!(@angular)/] 
      }, 

      { test: /\.scss$/, loader: "null" }, 
      { test: /\.css$/, loader: "null" }, 
      { test: /\.html$/, loader: "raw" }, 

      { 
       test: /\.(js|ts)$/, 
       include: [root("")], 
       loader: "istanbul-instrumenter-loader", 
       exclude: [/.+-spec\.ts$/, /\.e2e\.ts$/, NODE_MODULES], 
       enforce: 'post' 
      } 
     ] 
    } 
}; 
+0

धन्यवाद। अंततः मुझे वेबपैक बीटा 23-25 ​​अपग्रेड दस्तावेज मिला जिसमें यह मार्गदर्शन शामिल है। लेकिन यह सही समाधान है। – jkyoutsey

संबंधित मुद्दे