Tah*_*oon 5 elixir cowboy brunch phoenix-framework
在我的应用程序中,我创建了两个 java 脚本文件 -“app.js”和“vendor.js”。这些文件是通过“brunch build”在 priv/static/js 文件夹中正确生成的。但是当我使用牛仔服务器运行我的应用程序时,有时文件会加载到浏览器中,有时我会看到 404,即出现以下错误 -
GET http://localhost:4000/js/vendor.js 404 (Not Found)
GET http://localhost:4000/js/app.js
Run Code Online (Sandbox Code Playgroud)
这是我的早午餐配置:
exports.config = {
files: {
javascripts: {
joinTo: {
"js/app.js": /^(web\/static\/js)|(web\/static\/js\/*)|(node_modules\/*)/,
"js/vendor.js": [
"web/static/vendor/jquery/dist/jquery.min.js",
"web/static/vendor/bootstrap-sass/assets/javascripts/bootstrap.min.js"
],
'js/ignoreThis.js': /^(web\/static\/vendor)/
},
order: {
before: []
}
},
stylesheets: {
joinTo: "css/app.css",
order: {
before: [],
after: [
"web/static/css/app.css"
]
}
},
templates: {
joinTo: "js/app.js"
}
},
conventions: {
assets: /^(web\/static\/assets)/
},
paths: {
watched: [
"web/static",
"test/static"
],
public: "priv/static"
},
plugins: {
babel: {
ignore: [/web\/static\/vendor\/js/]
}
},
modules: {
autoRequire: {
"js/app.js": ["web/static/js/app"]
}
},
npm: {
enabled: true
},
watcher: {
usePolling: true
}
};
Run Code Online (Sandbox Code Playgroud)
这是我的模板布局 -
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<!-- Metadata. -->
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="robots" content="follow, index, noarchive" />
<meta name="viewport" content="initial-scale=1.0, height=device-height, width=device-width" />
<title><%= @title %></title>
<base href="/" />
<!-- Stylesheets and styling. -->
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>" />
</head>
<body>
<!-- Main Content. -->
<section class="main">
<%= render @view_module, @view_template, assigns %>
</section>
<script src="<%= static_path(@conn, "/js/vendor.js") %>"></script>
<script src="<%= static_path(@conn, "/js/app.js") %>"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
986 次 |
| 最近记录: |