gpt4 book ai didi

javascript - Grunt Connect 服务器 CSS 文件为空

转载 作者:行者123 更新时间:2023-11-28 06:11:10 25 4
gpt4 key购买 nike

我正在使用 Grunt 连接网络服务器在本地提供 JS 和 CSS 文件。

Grunt-contrib-connect:https://github.com/gruntjs/grunt-contrib-connect

Grunt 任务如下所示:

connect: {
server: {
options: {
port: 9001,
base: '<%= templateDir %>/interface/build/',
livereload: true,
debug: true
}
}
}

它正确地提供 JS 文件,但提供的所有 CSS 文件都是空的。

以下是用于访问文件的本地 URL:

JS 网址:http://localhost:9001/production.js

enter image description here

CSS 网址:http://localhost:9001/production.css

enter image description here

非常感谢任何帮助或想法!

最佳答案

原来 templateDir 配置变量不为空,但没有导致错误。令我震惊的是,映射到的目录实际上与名称完全相同的文件存在。

解决方法是在注册任务时传入变量:

grunt.registerTask('serve', [
'set_config:templateDir:<%= pkg.templateDir %>',
'connect',
'watch'
]);

关于javascript - Grunt Connect 服务器 CSS 文件为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36169386/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com