[英]How to compile sass without gulp and laravel-elixir [ FIX ]
Firstly first you have to delete the node_modules folder from your project.首先,您必须从项目中删除 node_modules 文件夹。 To do this, type these commands :
为此,请键入以下命令:
Please note, copy the module name before deleting the package.json :)
请注意,在删除 package.json 之前复制模块名称:)
Now you will need a new package.json by doing this you need this command:现在你将需要一个新的 package.json 这样做你需要这个命令:
hit enter until the command-line comes back.按 Enter 直到命令行返回。
Now you need to install Node-Sass to do this, type this command:现在您需要安装Node-Sass来执行此操作,输入以下命令:
if there's a problem with permissions try it with sudo, like this:如果权限有问题,请尝试使用 sudo,如下所示:
After installing Node-sass you need to write Node-sass command, go to the package.json file and you will see something like this:安装Node-sass 后,你需要编写Node-sass命令,进入 package.json 文件,你会看到如下内容:
{
"name": "blog",
"version": "1.0.0",
"description": "Bla Bla Bla Bla ...",
"main": "gulpfile.js",
"directories": {
"test": "tests"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
},
"author": "",
"license": "ISC",
"dependencies": {
"bootstrap": "^4.4.1",
"jquery": "^3.4.1",
"node-sass": "^4.13.1"
}
}
In the scripts section add an scss command, under the test command, like this:在脚本部分添加一个 scss 命令,在 test 命令下,如下所示:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"scss": "node-sass resources/assets/sass -o public/css"
}
you can use --watch option, like this:您可以使用 --watch 选项,如下所示:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"scss": "node-sass --watch resources/assets/sass -o public/css"
}
Which means to watch a directory or file if there's a change, in other terms, it will compile all .scss files every time you hit CTRL + S
or CMD + S
.这意味着如果有更改,则监视目录或文件,换句话说,每次点击
CTRL + S
或CMD + S
时,它都会编译所有 .scss 文件。
And Finally, run the script:最后,运行脚本:
Many thanks to Zviad Sichinava .非常感谢Zviad Sichinava 。
Learn More about node-sass .了解有关node-sass 的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.