我正在将更少或CSS文件导入我的react组件,并且在我的以下示例项目中工作正常: https://github.com/digz6666/webpack-loader-test
但是当我使用Express Server实施SSR时,我将无法再将更少的文件导入我的react组件。它仅适用于index.js条目文件。 它引发以下异常:
[1] Error: Module parse failed: Unexpected token (2:0)
[1] You may need an appropriate loader to handle this file type.
[1] | // @import '~antd/dist/antd.css';
[1] > .trigger {
[1] | font-size: 18px;
[1] | line-height: 64px;
[1] at eval (webpack:///./src/client/layout/baseLayout.less?:1:7)
这是我使用SSR的示例项目: https://github.com/digz6666/webpack-loader-test/tree/ssr
请取消注释以下文件中的样式,npm install和npm开始测试:
/src/client/layout/baseLayout.less
答案 0 :(得分:1)
我知道了,我的应用程序是同构的,因此我需要同构加载器。 以下是回答我的问题:How to import CSS file on Isomorphic React - Webpack
我应该使用https://github.com/catamphetamine/universal-webpack,因为https://github.com/catamphetamine/webpack-isomorphic-tools不再保持。
答案 1 :(得分:0)