Phoenix静态内容不会始终加载

时间:2016-10-05 12:46:41

标签: elixir phoenix-framework brunch cowboy

在我的应用程序中,我创建了两个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 

这是我的早午餐配置:

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
    }
};

这是我的模板布局 -

<!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>

0 个答案:

没有答案