- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
Angular 5 aspnetcore 2.0 是我的环境。
并且我将我的包更新为 Angular 5,并将 webpack.config.js
中的 AotPlugin
替换为 AngularCompilerPlugin
。在发布我的项目时,我遇到了这个错误。
TypeError: AngularCompilerPlugin is not a constructor
2017-12-07T06:25:19.8388691Z at module.exports (d:\a\1\s\web\source\webpack.config.js:48:13)
2017-12-07T06:25:19.8388916Z at requireConfig (d:\a\1\s\web\source\node_modules\webpack\bin\convert-argv.js:102:15)
2017-12-07T06:25:19.8389187Z at d:\a\1\s\web\source\node_modules\webpack\bin\convert-argv.js:109:17
2017-12-07T06:25:19.8389479Z at Array.forEach (native)
2017-12-07T06:25:19.8389687Z at module.exports (d:\a\1\s\web\source\node_modules\webpack\bin\convert-argv.js:107:15)
2017-12-07T06:25:19.8389914Z at Object.<anonymous> (d:\a\1\s\web\source\node_modules\webpack\bin\webpack.js:153:40)
2017-12-07T06:25:19.8390154Z at Module._compile (module.js:570:32)
2017-12-07T06:25:19.8390340Z at Object.Module._extensions..js (module.js:579:10)
2017-12-07T06:25:19.8390524Z at Module.load (module.js:487:32)
2017-12-07T06:25:19.8390881Z at tryModuleLoad (module.js:446:12)
2017-12-07T06:25:19.8569143Z d:\a\1\s\web\source\CA.IDM.PAdmin.Web.csproj(41,5): error MSB3073: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 1.
2017-12-07T06:25:19.9453100Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
2017-12-07T06:25:19.9454881Z ##[error]Dotnet command failed with non-zero exit code on the following projects : d:\a\1\s\web\source\CA.IDM.PAdmin.Web.csproj
所以我撤销了这个更改并在 webpack.config.js
中恢复了 AotPlugin
现在我的发布成功了。
实际上对于 Angular 5 使用 AngularCompilerPlugin
而不是 AotPlugin
。所以我的问题是我错过了什么吗?我在这里做错了什么?
webpack.config.js
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin ;
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
module.exports = (env) => {
// Configuration in common to both client-side and server-side bundles
const isDevBuild = !(env && env.prod);
const sharedConfig = {
stats: { modules: false },
context: __dirname,
resolve: { extensions: [ '.js', '.ts' ] },
output: {
filename: '[name].js',
publicPath: 'dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
},
module: {
rules: [
{ test: /\.ts$/, use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader', 'angular2-router-loader'] : '@ngtools/webpack' },
{ test: /\.html$/, use: 'html-loader?minimize=false' },
{ test: /\.css$/, use: [ 'to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
]
},
plugins: [new CheckerPlugin()]
};
// Configuration for client-side bundle suitable for running in browsers
const clientBundleOutputDir = './wwwroot/dist';
const clientBundleConfig = merge(sharedConfig, {
entry: { 'main-client': './ClientApp/boot.browser.ts' },
output: { path: path.join(__dirname, clientBundleOutputDir) },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
})
].concat(isDevBuild ? [
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[file].map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [
// Plugins that apply in production builds only
new webpack.optimize.UglifyJsPlugin(),
new AngularCompilerPlugin ({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.browser.module#AppModule'),
exclude: ['./**/*.server.ts']
})
])
});
// Configuration for server-side (prerendering) bundle suitable for running in Node
const serverBundleConfig = merge(sharedConfig, {
resolve: { mainFields: ['main'] },
entry: { 'main-server': './ClientApp/boot.server.ts' },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./ClientApp/dist/vendor-manifest.json'),
sourceType: 'commonjs2',
name: './vendor'
})
].concat(isDevBuild ? [] : [
// Plugins that apply in production builds only
new AngularCompilerPlugin ({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.server.module#AppModule'),
exclude: ['./**/*.browser.ts']
})
]),
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './ClientApp/dist')
},
target: 'node',
devtool: 'inline-source-map'
});
return [clientBundleConfig, serverBundleConfig];
};
包.json
{
"name": "Web5",
"private": true,
"version": "0.0.0",
"scripts": {
"test": "karma start ClientApp/test/karma.conf.js"
},
"devDependencies": {
"@angular/animations": "5.0.5",
"@angular/common": "5.0.5",
"@angular/compiler": "5.0.5",
"@angular/compiler-cli": "5.0.5",
"@angular/core": "5.0.5",
"@angular/forms": "5.0.5",
"@angular/http": "5.0.5",
"@angular/platform-browser": "5.0.5",
"@angular/platform-browser-dynamic": "5.0.5",
"@angular/platform-server": "5.0.5",
"@angular/router": "5.0.5",
"@ngtools/webpack": "1.8.5",
"@types/chai": "4.0.1",
"@types/jasmine": "2.5.53",
"@types/webpack-env": "1.13.0",
"angular2-router-loader": "0.3.5",
"angular2-template-loader": "0.6.2",
"aspnet-prerendering": "^3.0.1",
"aspnet-webpack": "^2.0.1",
"awesome-typescript-loader": "3.2.1",
"bootstrap": "3.3.7",
"chai": "4.0.2",
"css": "2.2.1",
"css-loader": "0.28.4",
"es6-shim": "0.35.3",
"event-source-polyfill": "0.0.9",
"expose-loader": "0.7.3",
"extract-text-webpack-plugin": "2.1.2",
"file-loader": "0.11.2",
"html-loader": "0.4.5",
"isomorphic-fetch": "2.2.1",
"jasmine-core": "2.6.4",
"jquery": "3.2.1",
"json-loader": "0.5.4",
"karma": "1.7.0",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-jasmine": "1.1.0",
"karma-webpack": "2.0.3",
"preboot": "4.5.2",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.10",
"rxjs": "5.5.4",
"style-loader": "0.18.2",
"to-string-loader": "1.1.5",
"typescript": "2.6.2",
"url-loader": "0.5.9",
"webpack": "2.5.1",
"webpack-hot-middleware": "2.18.2",
"webpack-merge": "4.1.0",
"zone.js": "0.8.12"
}
}
正如我在发布时检查的那样,它没有采用更新版本。会是什么原因呢?
12-07T06:23:03.8757490Z Web5 -> d:\a\1\s\web5.dll
2017-12-07T06:24:43.8922441Z Web5@0.0.0 d:\a\1\s\web\
2017-12-07T06:24:43.8923186Z +-- @angular/animations@4.2.5
2017-12-07T06:24:43.8923751Z +-- @angular/common@4.2.5
2017-12-07T06:24:43.8925363Z +-- @angular/compiler@4.2.5
2017-12-07T06:24:43.8935332Z +-- @angular/compiler-cli@4.2.5
2017-12-07T06:24:43.8936589Z | `-- minimist@1.2.0
2017-12-07T06:24:43.8936969Z +-- @angular/core@4.2.5
2017-12-07T06:24:43.8937290Z +-- @angular/forms@4.2.5
2017-12-07T06:24:43.8937696Z +-- @angular/http@4.2.5
2017-12-07T06:24:43.8938023Z +-- @angular/platform-browser@4.2.5
2017-12-07T06:24:43.8938348Z +-- @angular/platform-browser-dynamic@4.2.5
2017-12-07T06:24:43.8938687Z +-- @angular/platform-server@4.2.5
2017-12-07T06:24:43.8939007Z +-- @angular/router@4.2.5
2017-12-07T06:24:43.8939341Z +-- @angular/tsc-wrapped@4.2.5
最佳答案
如果不看您的 webpack.config 就很难分辨。
这是我喜欢的方式:
const AotPlugin = require('@ngtools/webpack').AngularCompilerPlugin;
plugins: [
new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'src/app/app.module#AppModule')
})
]
关于 Angular 5 类型错误 : AngularCompilerPlugin is not a constructor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47690469/
我正在尝试编写一个相当多态的库。我遇到了一种更容易表现出来却很难说出来的情况。它看起来有点像这样: {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE
谁能解释一下这个表达式是如何工作的? type = type || 'any'; 这是否意味着如果类型未定义则使用“任意”? 最佳答案 如果 type 为“falsy”(即 false,或 undef
我有一个界面,在IAnimal.fs中, namespace Kingdom type IAnimal = abstract member Eat : Food -> unit 以及另一个成功
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: What is the difference between (type)value and type(va
在 C# 中,default(Nullable) 之间有区别吗? (或 default(long?) )和 default(long) ? Long只是一个例子,它可以是任何其他struct类型。 最
假设我有一个案例类: case class Foo(num: Int, str: String, bool: Boolean) 现在我还有一个简单的包装器: sealed trait Wrapper[
这个问题在这里已经有了答案: Create C# delegate type with ref parameter at runtime (1 个回答) 关闭 2 年前。 为了即时创建委托(dele
我正在尝试获取图像的 dct。一开始我遇到了错误 The function/feature is not implemented (Odd-size DCT's are not implemented
我正在尝试使用 AFNetworking 的 AFPropertyListRequestOperation,但是当我尝试下载它时,出现错误 预期的内容类型{( “应用程序/x-plist” )}, 得
我在下面收到错误。我知道这段代码的意思,但我不知道界面应该是什么样子: Element implicitly has an 'any' type because index expression is
我尝试将 SignalType 从 ReactiveCocoa 扩展为自定义 ErrorType,代码如下所示 enum MyError: ErrorType { // .. cases }
我无法在任何其他问题中找到答案。假设我有一个抽象父类(super class) Abstract0,它有两个子类 Concrete1 和 Concrete1。我希望能够在 Abstract0 中定义类
我想知道为什么这个索引没有用在 RANGE 类型中,而是用在 INDEX 中: 索引: CREATE INDEX myindex ON orders(order_date); 查询: EXPLAIN
我正在使用 RxJava,现在我尝试通过提供 lambda 来订阅可观察对象: observableProvider.stringForKey(CURRENT_DELETED_ID) .sub
我已经尝试了几乎所有解决问题的方法,其中包括。为 提供类型使用app.use(express.static('public'))还有更多,但我似乎无法为此找到解决方案。 index.js : imp
以下哪个 CSS 选择器更快? input[type="submit"] { /* styles */ } 或 [type="submit"] { /* styles */ } 只是好
我不知道这个设置有什么问题,我在 IDEA 中获得了所有注释(@Controller、@Repository、@Service),它在行号左侧显示 bean,然后转到该 bean。 这是错误: 14-
我听从了建议 registering java function as a callback in C function并且可以使用“简单”类型(例如整数和字符串)进行回调,例如: jstring j
有一些 java 类,加载到 Oracle 数据库(版本 11g)和 pl/sql 函数包装器: create or replace function getDataFromJava( in_uLis
我已经从 David Walsh 的 css 动画回调中获取代码并将其修改为 TypeScript。但是,我收到一个错误,我不知道为什么: interface IBrowserPrefix { [
我是一名优秀的程序员,十分优秀!