richjdsmith

richjdsmith

Brunch Config Instructions for Bulma

Anyone willing to explain to me how to include the Bulma CSS Framework with Brunch? I haven’t warped my head around brunch yet. Here’s what I have done so far.

  1. Installed sass-brunch
    $ cd assets && npm install --save sass-brunch

  2. Installed bulma
    $ npm install --save bulma

  3. Removed bootstrap
    $ echo "" > css/phoenix.css

  4. Added sass-brunch to my Brunch Config (I think this is where I went wrong)
    Gist to brunch-config (how do I embed?)

Summary
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": /^js/,
      //   "js/vendor.js": /^(?!js)/
      // }
      //
      // To change the order of concatenation of files, explicitly mention here
      // order: {
      //   before: [
      //     "vendor/js/jquery-2.1.1.js",
      //     "vendor/js/bootstrap.min.js"
      //   ]
      // }
    },
    stylesheets: {
      joinTo: "css/app.css"
    },
    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 "/assets/static". Files in this directory
    // will be copied to `paths.public`, which is "priv/static" by default.
    assets: /^(static)/
  },

  // Phoenix paths configuration
  paths: {
    // Dependencies and current project directories to watch
    watched: ["static", "css", "scss", "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/]
    },
    sass: {
      includePaths: ['node_modules/bulma/']
    }
  },

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

  npm: {
    enabled: true
  }
};
  1. Renamed app.css to app.scss
    $ cd assets/css; mv app.css app.scss

  2. Imported Bulma into my app.scss
    @import "bulma";

  3. Added a folder for my scss files
    $ mkdir assets/scss $ touch assets/scss/custom.scss

  4. Just added some dummy code to my new custom.scss
    @import "../node_modules/bulma/sass/utilities/initial-variables"; $primary: $red

  5. Added my custom css to app.scss below the import for bulma.
    @import "../scss/custom";

I did all this following instructions from @kaputse (whom it appears is on here! :D)

Unfortunately, doing all this, compiling of css/app.scss failed :frowning:

[debug] Processing with LaterReviewWeb.PageController.index/2
  Parameters: %{}
  Pipelines: [:browser]
[info] Sent 200 in 352µs
18:08:27 - info: Reloading watcher...
(node:33658) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added. Use emitter.setMaxListeners() to increase limit
18:08:29 - error: Compiling of css/app.scss failed. L2:1:
   File to import not found or unreadable: bulma
   Parent style sheet: /Users/richsmith/later_review/assets/css/app.scss Error: File to import not found or unreadable: bulma
          Parent style sheet: /Users/richsmith/later_review/assets/css/app.scss

   >> @import "bulma";
      ^
Stack trace was suppressed. Run with `LOGGY_STACKS=1` to see the trace.
[debug] Live reload: priv/static/js/app.js
[debug] Live reload: priv/static/js/app.js 

Any help or suggestions would be appreciated and hopefully this can solve the issue for others. Cheers!

First 10 of 17 Posts Switch mode

OvermindDL1

OvermindDL1

If using scss make sure to list the proper import directories in the scss plugin configuration. :slight_smile:

richjdsmith

richjdsmith OP

Sorry for being a bit daft, but do you mind giving me an example? Should I be using:

  // Configure your plugins
  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/vendor/]
    },
    sass: {
      includePaths: ['node_modules/bulma/sass']
                                   //HERE? ^
    }
  },
OvermindDL1

OvermindDL1

Something like that should work, but currently in the project that I’m still using brunch in I’m just using:

  plugins: {
    // ...other plugin configurationss here...
    cleancss: {
      level: 0, // level 1+ breaks the CSS, the fonts vanish, some blocks vanish, wtf...
    },
    sass: {
      options: {
        includePaths: [
          'node_modules'
        ]
        // debug: 'comments', // 'debug',
      },
      allowCache: true,
      sourceMapEmbed: true,
      precision: 8,
      modules: false
    },
    postcss: {
      processors: [
        require('autoprefixer')(['last 8 versions']),
        require('csswring')({
          // preserveHacks: true,
          // removeAllComments: true,
        })
      ]
    },
    // ...and still more configurations...
  },

Then I use the full ‘project’ path to it. I found it helps keep things obvious of what comes from where. ^.^

cpgo

cpgo

I did this quite a while ago so I don’t know if its working
https://github.com/cpgo/authen

dwyd

dwyd

The following configuration worked for me when I added Bulma to a Phoenix 1.3 project… your npm steps look correct at a glance. Make sure sass and bulma are in node_modules.

package.json should have something similar after NPM install

# ./assets/package.json
{
...
  "dependencies": {
...
    "bulma": "^0.5.0",
...
  },
  "devDependencies": {
...
    "sass-brunch": "^2.10.4",
...
  }
}

Update brunch-config.js

# ./assets/brunch-config.js
exports.config = {
  files: {
    stylesheets: {
...
      joinTo: "css/app.css",
      order: {
        after: [ "css/app.scss"]
      }
    },
...
  },

...

  // Configure your plugins
  plugins: {
...
    sass: {
      mode: 'native',
      options: {
        includePaths: ['node_modules/bulma']
      }
    }
  },
...
};

Add app.scss to ./assets/css/

# ./assets/css/app.scss
@import "bulma";

You can do all your overrides in app.scss

Compile the app

iex -S mix phx.server

richjdsmith

richjdsmith OP

Sorry to be such a bother, but I am still getting:

22:46:54 - info: compiled 6 files into 2 files, copied 3 in 1.9 sec 22:46:54 - error: Cannot read property 'verbose' of undefined

This is my app.scss:

/* This file is for your main application css. */
@import "bulma";

My app.css is empty.

Here is my package.json:

  "dependencies": {
    "phoenix": "file:../deps/phoenix",
    "phoenix_html": "file:../deps/phoenix_html"
  },
  "devDependencies": {
    "bulma": "^0.6.0",
    "babel-brunch": "6.1.1",
    "brunch": "2.10.9",
    "clean-css-brunch": "2.10.0",
    "copycat-brunch": "^1.1.0",
    "sass-brunch": "^2.10.4",
    "uglify-js-brunch": "2.10.0"
  }

and the important bits from my brunch-config:

...
},
    stylesheets: {
      joinTo: "css/app.css",
      order: {
        after: [ "css/app.scss"]
      }
    },
...

  // Configure your plugins
  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/vendor/]
    },
    sass: {
      mode: 'native',
      options: {
        includePaths: ['node_modules/bulma']
      }
    }
  },
...

Any ideas?

cmkarlsson

cmkarlsson

I just set bulma + phoenix 1.3 up a couple of days ago and I followed this gist:

But replaced bootstrap with bulma.

With the exception that my app.scss looks like this:

@import "node_modules/bulma/bulma";

and my brunch config sass option looks like this:

  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/vendor/]
    },
    sass: {
        options: {
            includePaths: ["node_modules/bulma/sass"],
            precision: 8
        }
    }
  },
dwyd

dwyd

Can you try changing this…

to this…

after: [ "css/app.sass"]

but leave the actual file like this css/app.scss?

richjdsmith

richjdsmith OP

It made no difference.

Still getting:
23:36:28 - error: Cannot read property 'verbose' of undefined Stack trace was suppressed. Run with LOGGY_STACKS=1 to see the trace.

:confused:

richjdsmith

richjdsmith OP

I also tried deleting node_modules and npm install’ing again to no avail.

Where Next?

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement