我正在关注此博文,但字体不会被复制。
http://cloudless.studio/articles/4-installing-font-awesome-from-npm-in-phoenix
问题的本质是什么? 不包括字体文件夹
我希望包含fonts文件夹
package.json
内容{
"repository": {},
"license": "MIT",
"scripts": {
"deploy": "brunch build --production",
"watch": "brunch watch --stdin"
},
"dependencies": {
"font-awesome": "^4.6.3",
"google-maps": "^3.2.1",
"phoenix": "file:deps/phoenix",
"phoenix_html": "file:deps/phoenix_html",
"sass-brunch": "^2.6.3"
},
"devDependencies": {
"babel-brunch": "~6.0.0",
"brunch": "~2.8.0",
"clean-css-brunch": "~2.0.0",
"css-brunch": "~2.0.0",
"javascript-brunch": "~2.0.0",
"uglify-js-brunch": "~2.0.1"
}
}
exports.config = {
// See http://brunch.io/#documentation for docs.
files: {
javascripts: {
joinTo: "js/app.js"
// To use a separate vendor.js bundle, specify two files path
// http://brunch.io/docs/config#-files-
// joinTo: {
// "js/app.js": /^(web\/static\/js)/,
// "js/vendor.js": /^(web\/static\/vendor)|(deps)/
// }
//
// To change the order of concatenation of files, explicitly mention here
// order: {
// before: [
// "web/static/vendor/js/jquery-2.1.1.js",
// "web/static/vendor/js/bootstrap.min.js"
// ]
// }
},
stylesheets: {
joinTo: "css/app.css",
order: {
after: ["web/static/css/app.css"] // concat app.css last
}
},
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)/,
/^(node_modules\/font-awesome)/
]
},
// Phoenix paths configuration
paths: {
// Dependencies and current project directories to watch
watched: [
"web/static",
"test/static",
'node_modules/font-awesome/fonts',
],
// 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
}
};
答案 0 :(得分:3)
从最近的早午餐版本开始,Brunch将不会包含通过node_modules
提供的非JavaScript或CSS资源。
指南here指出,包含非JavaScript或CSS资产的资产的唯一方法是手动复制它们。它建议通过postinstall
挂钩在npm中执行此操作。
那么你的凤凰应用程序看起来怎么样?很简单..
你的package.json中的:
"scripts": {
"postinstall": "cp -R node_modules/font-awesome/fonts web/static/assets/fonts"
}
最终,我不认为这个解决方案很棒,但确实可以完成工作。在文章中,您列出了作者链接到一组great alternatives,因为他们意识到他们的方法不再适用于Brunch 2.8.2。
使用webpack的替代方案似乎是最好的选择之一。 Phoenix可以和webpack一起使用,他们甚至提供了how to do just that.
的简短指南答案 1 :(得分:3)
我使用copycat-brunch插件来做到这一点,非常简单。在brunch-config.js文件中,我做了:
plugins: {
copycat: {
fonts: [
"node_modules/font-awesome/fonts",
"node_modules/bootstrap/dist/fonts"
]
}
}
并将字体正确复制到priv / static / fonts。它也适用于图像。
答案 2 :(得分:0)
即使节点匹配,也不要将node_modules归类为“资产” 正则表达式