mimosa-webpackage Crash

24 views
Skip to first unread message

Ken Carpenter

unread,
Jun 12, 2014, 7:58:32 PM6/12/14
to mimo...@googlegroups.com
I'm taking over a single page app from another developer and want to Mimosa-ize (Mimosafy?) the project.

It has the following structure:
  • css
    • styles.less
  • js
    • the app's js files
  • lib
    • third party / vendor js files
  • img
    • image files
  • partials
    • HTML partials files
  • index.html
I can't change the file structure at this time, so I tweaked the config until I got it pretty much working.

Here is my mimosa-config.coffee in case it helps anyone in the future:

exports.config =
  modules: [
    "copy",
    "minify-js",
    "minify-css",
    "minify-img",
    "live-reload",
    "less",
    "web-package",
    "combine"
  ]
  watch:
    sourceDir: "."
    javascriptDir: "js"
    stylesheetsDir: "css"
    exclude: [/node_modules/, /lib/, /\.coffee/, /public/]
  vendor:
    javascripts: "lib"
  webPackage:
    appjs: undefined
  liveReload:
    enabled: true
  server:
    views:
      compileWith: "html"
      extension: "html"
      path:"."
    defaultServer:
      enabled: true

The regexes in the exlude should probably be tightened up, but they worked for this simple app.  These were added because:
  • /node_modules/ : to avoid compiling those files
  • /lib/ : to avoid compiling and linting the third party JS files
  • /\.coffee/ : to avoid warnings about having no module to handle .coffee files like mimosa-config.coffee
  • /public/ : to avoid Mimosa recursively generating public folders like public/public/public/public/public/js/filters.js.

I guess my main question is, is there a better way to do this without reorganizing the files?

The other thing is that I'd like to get the live reload ability with Mimosa's default server so I can tweak CSS and HTML & partials and see things reload.  When I try running mimosa watch --server though, it gives me the error:

  23:25:05 - WARN - Live-Reload module is configured, but is unable to find your server.  Did you forget to return it from your startServer function? Disabling Live-Reload.

I thought that with the Mimosa default server that I could serve up the index.html and all the other static files.  Is that right?  If so, what would I need to change in my config?

I guess I'd need to also include the socket.io and live reload lines in my index.html script tags.

Thanks,


Ken

Ken Carpenter

unread,
Jun 12, 2014, 9:49:41 PM6/12/14
to mimo...@googlegroups.com
Okay, for my second issue, I had accidentally removed the "server" module, so it's running the server now.

However, when I tried to load index.html, the browser got 404 errors, because the server cannot find the included js files in the lib folder and the js folder.

I fixed some of these by setting the server:base: to "/".

Then I noticed that my lib folder was not being copied down because I added it to the exclude list for the watch config.

To fix this, I removed it from the exclude of the watch config and added an exclude to jshint:

    jshint:
    exclude: [ /lib\// ]

Then I had an issue where the server generated an error when loading my page: Error: Failed to lookup view "lib"

This was fixed by turning on the defaultServer:onePager: true flag.

At that point everything was working except live-reload.  I added the lines below as mentioned in the Mimosa live reload page:

    <script src="/socket.io/socket.io.js"></script>
    <script src="/javascript/reload-client.js"></script>

This didn't quite work, as reload-client.js was found.  I quickly realized that I just needed to change javascript to js, then it all worked.

    <script src="/socket.io/socket.io.js"></script>
    <script src="/js/reload-client.js"></script>



Ken

Ken Carpenter

unread,
Jun 12, 2014, 10:08:50 PM6/12/14
to mimo...@googlegroups.com
Ooops...I forgot to update the title of this post.  I originally had a webpackage crash, but I fixed that and ran into the other issues described.

dbashford

unread,
Jun 19, 2014, 11:43:52 PM6/19/14
to mimo...@googlegroups.com
Playing a bit of catch up.

Need to go back through the first issue, lots of details in there, but it sounds like the 2nd issue is just a documentation thing, right?  The problem seems to be that the docs recommend /javascript/ but really its wherever javascriptDir is?

Ken Carpenter

unread,
Jun 20, 2014, 9:52:26 AM6/20/14
to mimo...@googlegroups.com
That would be a helpful addition to the docs.  Perhaps an example mimosa-config.coffee (or a skeleton) for a simple website with no server where the assets are not grouped in a separate folder.


Ken 
Reply all
Reply to author
Forward
0 new messages