0
"dotnet new angular"プロジェクト(Angular 4、Dotnet Core 2.0.0)を使用して、多くのwebpackエラーに苦労しています。Angular4プロジェクトのProd Error Webpack
私のプロジェクトは開発には問題ありません。しかし、私が "ドットネットパブリッシュ"をしようとすると、 "webpack --env.prod"を使用しています。これが原因です。私はそれがAOTに関連していると思う。 この最後の問題は、私を超えていると私は、このエラーの原因となっている見つけることができません。ここで
ERROR in ./ClientApp/boot.browser.ts
Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.module.browser.ngfactory' in '/Users/a2ron44/Projects/CryptoGoblin/ClientApp' [/Users/a2ron44/Projects/CryptoGoblin/CryptoGoblin.csproj]
@ ./ClientApp/boot.browser.ts 5:0-95
Child
Hash: 0db56caee944b1d990af
Time: 14368ms
Asset Size Chunks Chunk Names
main-server.js 1.81 MB 0 [emitted] [big] main-server
ERROR in ./ClientApp/boot.server.ts
Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.module.server.ngfactory' in '/Users/a2ron44/Projects/CryptoGoblin/ClientApp' [/Users/a2ron44/Projects/CryptoGoblin/CryptoGoblin.csproj]
@ ./ClientApp/boot.server.ts 8:0-94
/Users/a2ron44/Projects/CryptoGoblin/CryptoGoblin.csproj(48,5): error MSB3073: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2.
は私webpack.config.jsファイルです:
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const AotPlugin = require('@ngtools/webpack').AotPlugin;
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'] : '@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(), new webpack.DefinePlugin({ "global.GENTLY": false })]
};
// 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 AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.module.browser#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 AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.module.server#AppModule'),
exclude: ['./**/*.browser.ts']
})
]),
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './ClientApp/dist')
},
target: 'node',
devtool: 'inline-source-map'
});
return [clientBundleConfig, serverBundleConfig];
};
何か他のものがあります私は見ているべきですか?これは、あなたが角度5に更新されている場合は
{ test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, include: [/ClientApp/, /\$\$_gendir/], use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader'] : '@ngtools/webpack' },
で
{ test: /\.ts$/, use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader'] : '@ngtools/webpack' },
を交換することによって固定することができ
これは機能しませんでした。同じエラー。私はAngular上にいる4.2.5 – a2ron44
は、asp.netコアテンプレートから参照されているパッケージのangle4 *および現在の5バージョンについて、これを解決する 'include'ステートメントでそれを更新しました。 –
同じ問題。私は新しいドットネットの角度のあるプロジェクトを試してみようと思っています。私はこのプロジェクトで非常に多くのことを試みました。私は何かを混乱させました。しかし、助けてくれてありがとう。まったく新しいdotnet angleプロジェクトがうまくいきます。なぜ私の墜落はわからない。私は設定ファイルと実際の違いは見ません。 – a2ron44