繁体   English   中英

css-loader将不再将css导入节点,从而引发错误

[英]css-loader will not import css into node anymore, throwing error

最初,我有一个index.html页面,其中的div包含<div id="react-content"></div元素。 我现在将把手作为模板语言包含在内,以服务于将响应ui元素渲染为字符串。

问题是,我正在使用css-loader将css导入到我的节点项目中,并且不再导入。 当我使用index.html文件时,它可以工作,但现在不行,节点抛出一个错误(不是webpack)。 我宁愿不将样式表作为<link />包含在公共目录中。 我想不出发生这种情况的原因。

错误

SyntaxError: /Users/***/Documents/Isomorphic React-Node/
Restuarant /src/components/homePageStyle.css: Unexpected token (6:0)

    import React, {Component}  from 'react';
    import PropTypes from 'prop-types';
    import HeaderMenu from './HeaderMenu';
    import MainVisualDisplay from './MainVisualDisplay';
    import homePageStyle from './homePageStyle.css';

    //HomePage component
     const HomePage = () => 
    {  
    return (

    <div>
        <HeaderMenu item1="Menu" item2="Locations" item3="About Us"/>
    </div>
    )     
}
//
const forHeaderMenu = () => (
    HomePage.item1: PropTypes.string.isRequired,
    HomePage.item2: PropTypes.string.isRequired,
    HomePage.item3: PropTypes.string.isRequired
)

const forMainVisualDisplay = () =>
(
    HomePage.displayImages: PropTypes.array
)

HomePage.propTypes = {
        forHeaderMenu,
        forMainVisualDisplay
    };

export default HomePage;

弄清楚了。 Node仅在知道.js时才尝试编译.css扩展名。 我需要扩展。

require.extensions['.css'] = () => {
  return;
};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM