在凤凰城可以这样完成:
您需要在 package.json 文件中包含 sass-brunch 包并运行 npm-install 例如
{
"repository": {
},
"dependencies": {
"brunch": "^1.8.5",
"babel-brunch": "^5.1.1",
"clean-css-brunch": ">= 1.0 < 1.8",
"css-brunch": ">= 1.0 < 1.8",
"javascript-brunch": ">= 1.0 < 1.8",
"sass-brunch": "^1.8.10",
"uglify-js-brunch": ">= 1.0 < 1.8"
}
}
现在您将位于 web/static/css/app.css 的 app.css 文件更改为 app.scss。从这里导入所有的 css/sass 文件(我个人将 bootstrap 添加到 css web/static/vendor/css/bootstrap.scss 下的 vendor 文件夹)例如
@import "../vendor/css/bootstrap";
下一部分可能是您难以弄清楚的部分,因为我 =o)。您对 javascript 文件所做的就是在 brunch-config.js 文件中要求它们,如下所示:
exports.config = {
// See http://brunch.io/#documentation for docs.
files: {
javascripts: {
joinTo: "js/app.js",
order: {
before: [
"web/static/vendor/js/jquery.min.js",
"web/static/vendor/js/bootstrap.min.js",
"web/static/vendor/js/scripts.js"
]
}
},
stylesheets: {
joinTo: "css/app.css"
},
templates: {
joinTo: "js/app.js"
}
},
conventions: {
// This option sets where we should place non-css and non-js assets in.
// By default, we set this to "/web/static/assets". Files in this directory
// will be copied to `paths.public`, which is "priv/static" by default.
assets: /^(web\/static\/assets)/
},
// Phoenix paths configuration
paths: {
// Dependencies and current project directories to watch
watched: [
"deps/phoenix/web/static",
"deps/phoenix_html/web/static",
"web/static",
"test/static"
],
// Where to compile files to
public: "priv/static"
},
// Configure your plugins
plugins: {
babel: {
// Do not use ES6 compiler in vendor code
ignore: [/web\/static\/vendor/]
}
},
modules: {
autoRequire: {
"js/app.js": ["web/static/js/app"]
}
},
npm: {
enabled: true
}
};