我正在尝试建立自己的webpack2/angular2样板,但是当我添加tslint时,我遇到了一堆错误:
ERROR in ./src/polyfills.ts Module build failed: Error at new FatalError (/Users/webpack/angular2-webpack2-starter/node_modules/tslint/lib/error.js:33:23) at Function.findConfiguration (/Users/webpack/angular2-webpack2-starter/node_modules/tslint/lib/configuration.js:97:15) at resolveOptions (/Users/webpack/angular2-webpack2-starter/node_modules/tslint-loader/index.js:26:64) at Object.module.exports (/Users/webpack/angular2-webpack2-starter/node_modules/tslint-loader/index.js:110:17) @ multi (webpack)-dev-server/client?http://localhost:7000 ./src/polyfills.ts ERROR in ./src/main.ts Module build failed: Error at new FatalError (/Users/webpack/angular2-webpack2-starter/node_modules/tslint/lib/error.js:33:23) at Function.findConfiguration (/Users/webpack/angular2-webpack2-starter/node_modules/tslint/lib/configuration.js:97:15) at resolveOptions (/Users/webpack/angular2-webpack2-starter/node_modules/tslint-loader/index.js:26:64) at Object.module.exports (/Users/webpack/angular2-webpack2-starter/node_modules/tslint-loader/index.js:110:17) @ multi (webpack)-dev-server/client?http://localhost:7000 ./src/main.ts ERROR in ./src/vendor.ts Module build failed: Error at new FatalError (/Users/webpack/angular2-webpack2-starter/node_modules/tslint/lib/error.js:33:23) at Function.findConfiguration (/Users/webpack/angular2-webpack2-starter/node_modules/tslint/lib/configuration.js:97:15) at resolveOptions (/Users/webpack/angular2-webpack2-starter/node_modules/tslint-loader/index.js:26:64) at Object.module.exports (/Users/webpack/angular2-webpack2-starter/node_modules/tslint-loader/index.js:110:17) @ multi (webpack)-dev-server/client?http://localhost:7000 ./src/vendor.ts
这是我的设置
const webpack = require('webpack'); const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin'); const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const helpers = require('./helpers'); const METADATA = { title: 'Angular2 Webpack2', baseUrl: '/', isDevServer: helpers.isWebpackDevServer() }; module.exports = { devtool: 'cheap-module-source-map', entry: { 'polyfills': './src/polyfills.ts', 'vendor': './src/vendor.ts', 'main': './src/main.ts' }, resolve: { extensions: ['.ts', '.js', '.json'] }, module: { rules: [ { enforce: 'pre', test: /\.ts$/, loader: 'tslint-loader', exclude: /(node_modules)/, }, { test: /\.ts$/, loaders: [ '@angularclass/hmr-loader', 'awesome-typescript-loader', 'angular2-template-loader', 'angular-router-loader' ], exclude: [/\.(spec|e2e)\.ts$/] }, { test: /\.html$/, loaders: ['html-loader'] }, { test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/, loader: 'file-loader?name=assets/[name].[hash].[ext]' }, { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader?sourceMap' }), exclude: helpers.root('src', 'app'), }, { test: /\.css$/, include: helpers.root('src', 'app'), loader: 'raw-loader' } ] }, plugins: [ new CommonsChunkPlugin({ name: ['app', 'vendor', 'polyfills'] }), new ExtractTextPlugin({ filename: 'bundle.css', disable: false, allChunks: true }), new HtmlWebpackPlugin({ template: 'src/index.html', title: METADATA.title, metadata: METADATA, inject: 'body', hash: true }), new LoaderOptionsPlugin({ options: { tslint: { emitErrors: true, failOnHint: true } } }) ] };
const webpackMerge = require('webpack-merge'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const commonConfig = require('./webpack.common.js'); const helpers = require('./helpers'); module.exports = webpackMerge(commonConfig, { devtool: 'cheap-module-source-map', output: { path: helpers.root('dist'), filename: '[name].bundle.js', sourceMapFilename: '[name].map', chunkFilename: '[id].chunk.js' }, plugins: [ new ExtractTextPlugin('[name].css') ], devServer: { port: 7000, historyApiFallback: true, stats: 'minimal', watchOptions: { aggregateTimeout: 300, poll: 1000 } } });
比如我的
// Polyfills // import 'ie-shim'; // Internet Explorer 9 support // import 'core-js/es6'; // Added parts of es6 which are necessary for your project or your browser support requirements. // TEST const ENV = 'developer'; import 'core-js/es6/symbol'; import 'core-js/es6/object'; import 'core-js/es6/function'; import 'core-js/es6/parse-int'; import 'core-js/es6/parse-float'; import 'core-js/es6/number'; import 'core-js/es6/math'; import 'core-js/es6/string'; import 'core-js/es6/date'; import 'core-js/es6/array'; import 'core-js/es6/regexp'; import 'core-js/es6/map'; import 'core-js/es6/set'; import 'core-js/es6/weak-map'; import 'core-js/es6/weak-set'; import 'core-js/es6/typed'; import 'core-js/es6/reflect'; // see issue https://github.com/AngularClass/angular2-webpack-starter/issues/709 // import 'core-js/es6/promise'; import 'core-js/es7/reflect'; import 'zone.js/dist/zone'; // Typescript emit helpers polyfill import 'ts-helpers'; if ('production' === ENV) { // Production } else { // Development Error.stackTraceLimit = Infinity; require('zone.js/dist/long-stack-trace-zone'); }
{ "rulesDirectory": [ "node_modules/codelyzer" ], "rules": { "class-name": true, "comment-format": [ true, "check-space" ], "curly": true, "eofline": true, "forin": true, "indent": [ true, "spaces" ], "label-position": true, "label-undefined": true, "max-line-length": [ true, 140 ], "member-access": false, "member-ordering": [ true, "static-before-instance", "variables-before-functions" ], "no-arg": true, "no-bitwise": true, "no-console": [ true, "debug", "info", "time", "timeEnd", "trace" ], "no-construct": true, "no-debugger": true, "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": false, "no-eval": true, "no-inferrable-types": true, "no-shadowed-variable": true, "no-string-literal": false, "no-switch-case-fall-through": true, "no-trailing-whitespace": true, "no-unused-expression": true, "no-unused-variable": true, "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, "object-literal-sort-keys": false, "one-line": [ true, "check-open-brace", "check-catch", "check-else", "check-whitespace" ], "quotemark": [ true, "single" ], "radix": true, "semicolon": [ "always" ], "triple-equals": [ true, "allow-null-check" ], "typedef-whitespace": [ true, { "call-signature": "nospace", "index-signature": "nospace", "parameter": "nospace", "property-declaration": "nospace", "variable-declaration": "nospace" } ], "variable-name": false, "whitespace": [ true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type" ], "directive-selector-name": [true, "camelCase"], "component-selector-name": [true, "kebab-case"], "directive-selector-type": [true, "attribute"], "component-selector-type": [true, "element"], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, "no-input-rename": true, "no-output-rename": true, "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, "directive-class-suffix": true, "directive-selector-prefix": [true, "my"], "component-selector-prefix": [true, "my"], "pipe-naming": [true, "camelCase", "my"] } }
请问有什么问题?提前致谢.
以防万一 https://bitbucket.org/whisher/angular2-webpack2-starter
您应该在package.json中添加codelyzer