我想将SASS添加到我的项目中,我正在使用Symfony 4.2.1 / Ubuntu 16.04
这是我使用的命令:
composer require encore
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
yarn install
所以我有一个webpack.config.js文件,文档说:
// webpack.config.js
// ...
Encore
// ...
// enable just the one you want
// processes files ending in .scss or .sass
.enableSassLoader()
// processes files ending in .less
.enableLessLoader()
// processes files ending in .styl
.enableStylusLoader()
;
有一个Encore对象。
在另一个教程中,我看到:
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist')
}
};
文档所说的完全不同类型的文件(第一个代码)
我的文件如下:
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
// any CSS you require will output into a single css file (app.css in this case)
require('../css/app.css');
// Need jQuery? Install it with "yarn add jquery", then uncomment to require it.
// const $ = require('jquery');
console.log('Hello Webpack Encore! Edit me in assets/js/app.js');
这又是另一种不同类型的文件!
我现在该怎么办? (“纱安装”后我什么也没做)
答案 0 :(得分:0)
您的第一个webpack.config
文件已设置为使用Encore,这是一个Symfony组件,该组件包装了webpack以提供易于使用的API。
第二个webpack.config
文件未使用Encore,这是传统的webpack设置。
由于您使用的是最新版本的Symfony,因此您可能希望使用第一个版本,该版本提供了更容易理解的API。
您可以在symfony文档中阅读有关Encore的更多信息: https://symfony.com/doc/current/frontend/encore/css-preprocessors.html