Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ice3.0约定式路由首次加载菜单时,css样式缺失 #6921

Open
LOL871230823 opened this issue Jun 21, 2024 · 3 comments
Open

ice3.0约定式路由首次加载菜单时,css样式缺失 #6921

LOL871230823 opened this issue Jun 21, 2024 · 3 comments
Labels

Comments

@LOL871230823
Copy link

Describe the bug

使用默认约定式路由,首次加载css样式缺失,路由切换后,再次返回正常加载
image
image

使用配置式路由,首次可正常加载css样式
image
image

image
image

Expected behavior

使用约定式路由策略时,可正常加载css资源

Actual behavior

使用默认约定式路由,首次加载css样式缺失,路由切换后,再次返回正常加载
image
image

Version of ice.js

3

Content of build.json or ice.config.mts

import { defineConfig } from '@ice/app';
import icestark from '@ice/plugin-icestark';
import fusion from '@ice/plugin-fusion';
import store from '@ice/plugin-store';
import request from '@ice/plugin-request';
import { addLoader, modifyLoader, removeLoader } from '@ice/webpack-modify';
export default defineConfig(() => ({
  ssg: false,
  hash: 'contenthash',
  plugins: [
    fusion({
    }),
    icestark({ type: 'framework' }),
    store(),
    request(),
  ],
  routes: {
    ignoreFiles: [
      'custom.tsx',
      '**/components/**',   // 如果每个页面下有 components 目录存放当前页面的组件,可以通过添加此配置忽略被解析成路由组件
    ],
    defineRoutes: (route) => {
      route('/', 'home/index.tsx');
    },
    config: []
  },

  webpack: (webpackConfig:any) => {
    webpackConfig.module.rules.push(      {
      test: /\.(mp4|webm|ogg|mp3|wav|avi|mov|flac|aac|mpeg|woff|woff2|eot|ttf|otf)$/i,
      type: 'asset',
      generator: {
        filename: 'assets/[hash][ext][query]',
      },
      parser: {
        dataUrlCondition: {
          maxSize: 10 * 1024, // 小于10KB的文件将被内联为Base64
        },
      },
    },);

    return modifyLoader(webpackConfig, {
      rule: '.less',
      loader: 'less-loader',
      options: (originOptions) => ({
        lessOptions: {
          javascriptEnabled: true, // 正确配置javascriptEnabled的方式
        },
      }),
    });
  },
}));

Additional context

No response

@ClarkXia
Copy link
Collaborator

看下能不能把业务逻辑去掉,建议保留样式来提供一个复现 demo

@ClarkXia
Copy link
Collaborator

样式如果是分包出去的,应该会随路由响应异步加载进来

@LOL871230823
Copy link
Author

后续有时间了,会给你提供一个demo,先mark一下

@ClarkXia ClarkXia changed the title ice3.0约定式路由首次加载菜单时,css样式确实 ice3.0约定式路由首次加载菜单时,css样式缺失 Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants