dongzhan2029 2017-10-13 16:51
浏览 88

Laravel预设React:执行`npm run dev`时遇到的问题

I have some issues with using React in Laravel 5.5. Every time I add or make changes to a component, I have to run npm run dev to compile the thing. When I do this the contents of css/app.css get reset, so I cannot write styles to this file.

Styles get unchanged if I have them in another CSS file, but I'd like to have my main styles written in css/app.css.

How can I do this?

  • 写回答

1条回答

  • duankang5285 2017-10-13 18:04
    关注

    Keep all your css styles in a file in your resources directory and add the below code to end of your webpack.mix.js file.

    mix.styles('path to your css file in resources directory', 'public/css/app.css');
    

    If you are using sass use the below code

    mix.sass('path to your css file in resources directory', 'public/css/app.css');
    

    Also you no need to run npm run dev each time you make changes to your components. just run npm run watch and it will continuously look for changes and re-compile the components if anything is changed.

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)