Jhipster Angular lazy-是否提供加载支持?
我已经在堆栈上读到了那个问题,但我再次要求对我的问题进行更多的描述 我尝试在成功登录后加载管理模块,并使用延迟加载加载该管理模块。我的项目结构如下 我尝试使用延迟加载来加载AdminModule 应用程序路由.module.tsJhipster Angular lazy-是否提供加载支持?,angular,jhipster,angular-routing,Angular,Jhipster,Angular Routing,我已经在堆栈上读到了那个问题,但我再次要求对我的问题进行更多的描述 我尝试在成功登录后加载管理模块,并使用延迟加载加载该管理模块。我的项目结构如下 我尝试使用延迟加载来加载AdminModule 应用程序路由.module.ts import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { LoginComponent } from "./login/log
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { LoginComponent } from "./login/login.component";
@NgModule({
imports:[
RouterModule.forRoot([
{ path:'', component:LoginComponent },
{ path:'admin',loadChildren:'app/admin/admin.module#AdminModule'}
])
],
exports:[
RouterModule
]
})
export class AppRouterModule{
constructor(){
console.log("App Router Module call");
}
}
管理路由.ts
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AdminComponent } from "./admin.component";
import { DashboardComponent } from "./dashboard/dashboard.component";
@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
component: AdminComponent,
children: [
{
path: '',
component: DashboardComponent,
pathMatch: 'full'
}
]
}
])
],
exports: [
RouterModule
]
})
export class AdminRoutingModule {
}
const webpack = require('webpack');
const path = require('path');
const commonConfig = require('./webpack.common.js');
const writeFilePlugin = require('write-file-webpack-plugin');
const webpackMerge = require('webpack-merge');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const ENV = 'dev';
const execSync = require('child_process').execSync;
const fs = require('fs');
const ddlPath = './build/www/vendor.json';
if (!fs.existsSync(ddlPath)) {
execSync('webpack --config webpack/webpack.vendor.js');
}
module.exports = webpackMerge(commonConfig({ env: ENV }), {
devtool: 'inline-source-map',
devServer: {
contentBase: './build/www',
proxy: [{
context: [
/* jhipster-needle-add-entity-to-webpack - JHipster will add entity api paths here */
'/api',
'/management',
'/swagger-resources',
'/v2/api-docs',
'/h2-console'
],
target: 'http://127.0.0.1:8080',
secure: false
}]
},
output: {
path: path.resolve('build/www'),
filename: 'app/[name].bundle.js',
chunkFilename: 'app/[id].chunk.js'
},
module: {
rules: [{
test: /\.ts$/,
loaders: [
'tslint-loader'
],
exclude: ['node_modules', new RegExp('reflect-metadata\\' + path.sep + 'Reflect\\.ts')]
}]
},
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 9000,
proxy: {
target: 'http://localhost:9060'
}
}, {
reload: false
}),
new ExtractTextPlugin('styles.css'),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
new writeFilePlugin(),
new webpack.WatchIgnorePlugin([
path.resolve('./src/test'),
])
]
});
如果我使用默认路由,它的工作很好,但当我在管理我得到了
错误。
找不到模块。和webpacketmptycontext
如果使用官方方式使用angular cli进行此操作,那么这是可行的
对我来说很好,但是使用Jhipster生成器会有一些错误
必须使用Jhipster
webpack.dev.js
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AdminComponent } from "./admin.component";
import { DashboardComponent } from "./dashboard/dashboard.component";
@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
component: AdminComponent,
children: [
{
path: '',
component: DashboardComponent,
pathMatch: 'full'
}
]
}
])
],
exports: [
RouterModule
]
})
export class AdminRoutingModule {
}
const webpack = require('webpack');
const path = require('path');
const commonConfig = require('./webpack.common.js');
const writeFilePlugin = require('write-file-webpack-plugin');
const webpackMerge = require('webpack-merge');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const ENV = 'dev';
const execSync = require('child_process').execSync;
const fs = require('fs');
const ddlPath = './build/www/vendor.json';
if (!fs.existsSync(ddlPath)) {
execSync('webpack --config webpack/webpack.vendor.js');
}
module.exports = webpackMerge(commonConfig({ env: ENV }), {
devtool: 'inline-source-map',
devServer: {
contentBase: './build/www',
proxy: [{
context: [
/* jhipster-needle-add-entity-to-webpack - JHipster will add entity api paths here */
'/api',
'/management',
'/swagger-resources',
'/v2/api-docs',
'/h2-console'
],
target: 'http://127.0.0.1:8080',
secure: false
}]
},
output: {
path: path.resolve('build/www'),
filename: 'app/[name].bundle.js',
chunkFilename: 'app/[id].chunk.js'
},
module: {
rules: [{
test: /\.ts$/,
loaders: [
'tslint-loader'
],
exclude: ['node_modules', new RegExp('reflect-metadata\\' + path.sep + 'Reflect\\.ts')]
}]
},
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 9000,
proxy: {
target: 'http://localhost:9060'
}
}, {
reload: false
}),
new ExtractTextPlugin('styles.css'),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.NamedModulesPlugin(),
new writeFilePlugin(),
new webpack.WatchIgnorePlugin([
path.resolve('./src/test'),
])
]
});
我有一个类似的问题,可以通过更改tsconfig aot中的值来修复它
必须将
编译器选项.module
设置为“commonjs”
您可以添加webpack.config.json吗?我找不到webpack.config.json文件,该文件包含webpack.common.js、webpack.dev.js、webpack.prod.js、,webpack.vender.jswebpack.dev.js是您的网页包配置,devi可以添加该文件。您是否将angular router loader
添加到webpack.common.js
?