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

ssr 开启时,引入 markdown 文件,编译报错 #6634

Open
cathy-zhao opened this issue Nov 8, 2023 · 6 comments
Open

ssr 开启时,引入 markdown 文件,编译报错 #6634

cathy-zhao opened this issue Nov 8, 2023 · 6 comments

Comments

@cathy-zhao
Copy link

cathy-zhao commented Nov 8, 2023

Describe the bug

ssr: false 时,引入 test.md 文件进行页面渲染时,一切正常。
ssr: true 时,没有引用 test.md 文件进行页面渲染时,一切正常。
ssr: true 时,引用 test.md 文件进行页面渲染时,报如下错误。

image image

Expected behavior

希望成功编译正常渲染页面

Actual behavior

No response

Version of ice.js

3.3.5

Content of build.json or ice.config.mts

export default defineConfig(() => ({
  ...
  ssr: true,
  compileDependencies: false,
  hash: false,
  plugins: [
    antd({
      importStyle: true,
      theme: {
        'primary-color': '#4357FF',
      }
    }),
    request(),
    store(),
    auth(),
  ],
  webpack: (webpackConfig) => {
    webpackConfig.module.rules.push({
      test: /\.md$/, // 匹配需要使用 raw-loader 处理的文件类型
      use: 'raw-loader', // 使用 raw-loader 处理匹配的文件
    });
    
    return webpackConfig;
  },
}));

Additional context

No response

@cathy-zhao cathy-zhao added the bug label Nov 8, 2023
@ClarkXia
Copy link
Collaborator

ClarkXia commented Nov 8, 2023

server 端执行未使用 webpack 链路,因此不支持解析 md 文件,后续我们增加下对应的处理的方式,如果是 raw-loader 的情况下可以直接使用 ?raw query 即可

@cathy-zhao
Copy link
Author

server 端执行未使用 webpack 链路,因此不支持解析 md 文件,后续我们增加下对应的处理的方式,如果是 raw-loader 的情况下可以直接使用 ?raw query 即可

大佬,我还是不太明白,方便贴一段代码不 @ClarkXia

@ClarkXia
Copy link
Collaborator

ClarkXia commented Nov 9, 2023

类似 import string from './text.txt?raw'

@cathy-zhao
Copy link
Author

类似 import string from './text.txt?raw'

感谢~

@cathy-zhao
Copy link
Author

cathy-zhao commented Nov 14, 2023

ssg: true 或者 ssr: true 时,npm run build 会报如下错误。
npm run start 时,正常。
ssg: false 且 ssr: false 时,npm run build 正常。

image

@ClarkXia 方便帮忙看看不

@ClarkXia
Copy link
Collaborator

可以提供一个复现的 demo 吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants