我已在https://github.com/joostvanrijn/webpacker创建了一个示例应用程序以完成,但这是我的问题:
# app/javascript/packs/stylesheets.scss
@import 'variables';
@import 'foo';
# app/javascript/packs/_variables.scss
$bar: #fff;
# app/javascript/packs/_foo.scss
body {
color: $bar;
}
现在,当我运行/bin/webpack-dev-server
时,我得到了
Undefined variable: "$bar".
更重要的是
[84] ./app/javascript/packs/_foo.scss 988 bytes {2} [built] [failed] [1 error]
似乎Rails / webpacker编译所有文件而不仅仅是stylesheets.scss
答案 0 :(得分:2)
我终于找到了答案。
来自Webpacker自述文件:
The configuration for what Webpack is supposed to compile by default
rests on the convention that every file in app/javascript/packs/*
(default) or whatever path you set for source_entry_path in the
webpacker.yml configuration is turned into their own output files (or
entry points, as Webpack calls it).
因此,通过将sass partials移动到另一个文件夹,现在只编译stylesheets.scss。