在凤凰1.3升级后,app.js未加载

时间:2017-08-30 09:18:09

标签: javascript elixir phoenix-framework brunch

我更新了我的凤凰1.2到1.3 the phoenix upgrade description

现在assets/js/app.js无法加载: Uncaught Error: Cannot find module 'js/app' from '/'

调试问题后,我发现预期的模块是app而不是js/app

当我将brunch-config.js autoRequire modules中的模块名称更改为["app"]而不是["js/app"]时,它可以正常工作。我不明白我的应用中出现的问题或问题,默认设置无效。

这是我的assets/brunch-config.js

exports.config = {
  // See http://brunch.io/#documentation for docs.
  files: {
    javascripts: {
      joinTo: "js/app.js"

    },
    stylesheets: {
      joinTo: "css/app.css",
      order: {
        after: ["../priv/static/css/app.css"] // concat app.css last
      }
    },
    templates: {
      joinTo: "js/app.js"
    }
  },

  conventions: {
    assets: /^(static)/
  },

  // Phoenix paths configuration
  paths: {
    // Dependencies and current project directories to watch
    watched: ["static", "css", "js", "vendor"],

    // Where to compile files to
    public: "../priv/static"
  },

  // Configure your plugins
  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/vendor/]
    },
    copycat: {
      "fonts": ["node_modules/font-awesome/fonts"] // copy node_modules/font-awesome/fonts/* to priv/static/fonts/
    },
    sass: {
      options: {
        includePaths: [
          "node_modules/bootstrap-sass/assets/stylesheets",
          "node_modules/font-awesome/scss"
        ], // tell sass-brunch where to look for files to @import
        precision: 8 // minimum precision required by bootstrap-sass 
      }
    }
  //sass: {
    //   mode: "native" // This is the important part!
    // },
  },

  modules: {
    autoRequire: {
      "js/app.js": ["js/app"]
    }
  },

  npm: {
    enabled: true,
    globals: {
      $: 'jquery',
      jQuery: 'jquery'
    }
  }
};

我的assets/js/app.js就在这里:

import "phoenix_html"
import "./datetimepicker"  

感谢任何帮助,琐事或想法来理解/解决问题。

1 个答案:

答案 0 :(得分:3)

问题与早午餐版本有关。 更新早午餐:

brunch@2.10.10

解决了这个问题。