【发布时间】:2020-02-04 00:26:15
【问题描述】:
我第一次尝试在新的 .Net Core 3.1 Web 应用程序上设置 grunt-sass。我已经完成了 MSFT 的步骤,将 grunt 添加到此处概述 here 的项目中,然后使用 grunt-sass 指令 here 中的步骤对其进行了修改。
然而,这会导致任务运行器资源管理器声明没有找到任务。 这是我的 package.json:
{
"name": "chapelstudios_www",
"version": "0.0.2",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://me@bitbucket.org/me/chapelstudios_www.git"
},
"author": "mr",
"license": "ISC",
"homepage": "https://bitbucket.org/me/chapelstudios_www#readme",
"private": true,
"devDependencies": {
"grunt": "^1.0.4",
"grunt-cli": "^1.3.2",
"grunt-sass": "^3.1.0",
"node-sass": "^4.13.1"
},
"dependencies": {
"gulp": "^4.0.2"
}
}
这是我的 gruntfile.js:
const sass = require('node-sass');
require('load-grunt-tasks')(grunt);
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Sass
sass: {
options: {
implementation: sass,
sourceMap: true, // Create source map
outputStyle: 'compressed' // Minify output
},
dist: {
files: [
{
expand: true, // Recursive
cwd: "Styles", // The startup directory
src: ["**/*.scss"], // Source files
dest: "wwwroot/css", // Destination
ext: ".css" // File extension
}
]
}
}
});
// Load the plugin
grunt.loadNpmTasks('grunt-sass');
// Default task(s).
grunt.registerTask('default', ['sass']);
};
我不确定如何获得更详细的错误信息,但已将问题追踪到
const sass = require('node-sass');
grunt-sass 指令所需的行。如果我将其更改为旧教程推荐的字符串“sass”,则任务会显示,但在我尝试实际运行它时会失败。
我还从项目目录中提升的 powershell 窗口运行了以下安装,以确保它们已安装到本地项目中,因为我听说这是一个主要问题:
npm install
npm install grunt
npm install grunt-cli
npm install --save-dev node-sass grunt-sass
在这一点上,我没有想法,但我是新手,所以我确定我错过了一些明显的东西。
【问题讨论】:
-
我也有类似的问题。我正在使用 Visual Studio for Mac 并安装了任务资源管理器。但是我总是得到错误: Failed to load /Users/xxxx/Developer/Projects/xxx/xxx/Gruntfile.js ApplicationName='grunt', CommandLine='--no-color --tasks "/Users/xxxx/Library /Application Support/VisualStudio/8.0/LocalInstall/Addins/MonoDevelop.TaskRunnersBundle.0.1/GruntScript" md-grunt-task-list', CurrentDirectory='/Users/xxxx/Developer/Projects/xxx/xxx', Native error= 不能找到指定的文件
-
这个问题解决了吗?
标签: gruntjs visual-studio-2019 node-sass .net-core-3.1 grunt-sass-lint