shahryarjb

shahryarjb

Some bootstrap4's css doesn't load in my phoenix project

Hello , I have updated phoenix css to bootstrap4, but some bootstrap4’s css doesn’t load in my phoenix project, for example in phoenix

30%20pm

in html file

40%20pm

I checked this and I know the css line doesn’t exist, weblayers expansion in chrome shows me that it’s bootstrap4

my

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",
      order: {
        after: ["priv/static/css/app.scss"]
      }
    },
    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", "js", "vendor","scss", "fonts"],
    // Where to compile files to
    public: "../priv/static"
  },

  // Configure your plugins
  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
      ignore: [/vendor/]
    },
    sass: {
      mode: 'native',
      options: {
        includePaths: ["node_modules/bootstrap/scss", "node_modules/font-awesome/scss"], // Tell sass-brunch where to look for files to @import
        precision: 8 // Minimum precision required by bootstrap-sass
      }
    },
    copycat: {
      "fonts" : ["static/fonts", "node_modules/font-awesome/fonts"],
      verbose : false, //shows each file that is copied to the destination directory
      onlyChanged: true //only copy a file if it's modified time has changed (only effective when using brunch watch)
    }
  },

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

  npm: {
    enabled: true,
    globals: { // Bootstrap's JavaScript requires both '$' and 'jQuery' in global scope
      $: 'jquery',
      jQuery: 'jquery',
      Tether: 'tether',
      Popper: 'popper.js',
      bootstrap: 'bootstrap', // Require Bootstrap's JavaScript globally
    }
  }
};

and I added these in asset/css/app.css

add @import 'font-awesome';
add @import 'bootstrap';

if I rename web/static/css/app.css to web/static/css/app.scss, I will have this error :

12:28:16 - error: Compiling of css/app.scss failed. L1:50: 
   Invalid CSS after "...ication css. */": expected 1 selector or at-rule, was "add @import 'font-a" 
           
   >>  file is for your main application css. */
      ------------------------------------------^
Stack trace was suppressed. Run with `LOGGY_STACKS=1` to see the trace. 
12:28:16 - info: removed app.css and wrote 2 cached files into app.css in 303 ms
19 Jul 12:28:16 - info: [copycat] copied 0 files (1 files were not modified)
19 Jul 12:28:16 - info: [copycat] copied 0 files (6 files were not modified)

I did these :

npm install --save-dev sass-brunch
npm install --save font-awesome
npm install --save copycat-brunch
npm install --save jquery
npm install --save bootstrap
npm install --save tether (bootstrap dep)
npm install --save popper.js (bootstrap dep)

by Installing Bootstrap 4 + Font Awesome from NPM in Phoenix Framework using sass · GitHub

how do I fix it?

First 6 of 6 Posts! Switch mode

dokuzbir

dokuzbir

I am not sure if you added like that. You should add like that.

@import 'font-awesome'
@import 'bootstrap'

And rename to app.scss

shahryarjb

shahryarjb

Hi, now ,I rename web/static/css/app.css to web/static/css/app.scss, but :

[debug] ** (Phoenix.Router.NoRouteError) no route found for GET /css/font-awesome (TrangellHtmlSiteWeb.Router)
    (trangell_html_site_web) lib/trangell_html_site_web/router.ex:1: TrangellHtmlSiteWeb.Router.__match_route__/4
    (trangell_html_site_web) lib/phoenix/router.ex:307: TrangellHtmlSiteWeb.Router.call/2
    (trangell_html_site_web) lib/trangell_html_site_web/endpoint.ex:1: TrangellHtmlSiteWeb.Endpoint.plug_builder_call/2
    (trangell_html_site_web) lib/plug/debugger.ex:122: TrangellHtmlSiteWeb.Endpoint."call (overridable 3)"/2
    (trangell_html_site_web) lib/trangell_html_site_web/endpoint.ex:1: TrangellHtmlSiteWeb.Endpoint.call/2
    (plug) lib/plug/adapters/cowboy/handler.ex:16: Plug.Adapters.Cowboy.Handler.upgrade/4
    (cowboy) /Applications/MAMP/htdocs/elixir-ex-source/Trangell_Main/trangell_html_site_umbrella/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

[debug] ** (Phoenix.Router.NoRouteError) no route found for GET /css/bootstrap (TrangellHtmlSiteWeb.Router)
    (trangell_html_site_web) lib/trangell_html_site_web/router.ex:1: TrangellHtmlSiteWeb.Router.__match_route__/4
    (trangell_html_site_web) lib/phoenix/router.ex:307: TrangellHtmlSiteWeb.Router.call/2
    (trangell_html_site_web) lib/trangell_html_site_web/endpoint.ex:1: TrangellHtmlSiteWeb.Endpoint.plug_builder_call/2
    (trangell_html_site_web) lib/plug/debugger.ex:122: TrangellHtmlSiteWeb.Endpoint."call (overridable 3)"/2
    (trangell_html_site_web) lib/trangell_html_site_web/endpoint.ex:1: TrangellHtmlSiteWeb.Endpoint.call/2
    (plug) lib/plug/adapters/cowboy/handler.ex:16: Plug.Adapters.Cowboy.Handler.upgrade/4
    (cowboy) /Applications/MAMP/htdocs/elixir-ex-source/Trangell_Main/trangell_html_site_umbrella/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

there is still that problem!!

dokuzbir

dokuzbir

I am not familiar phoenix 1.2 folder structure. From error it is looking static directory for bootstrap and fontawesome but should look node modules folder. You can try something like that.

@import "node_modules/bootstrap/scss/bootstrap";
shahryarjb

shahryarjb

I did this before but it didn’t work :frowning_face:

shahryarjb

shahryarjb

I checked again and I saw the bootstrap was loaded in my code , but the css needs !important‍ to load.

phoenix css has a conflict with Bootstrap

dokuzbir

dokuzbir

you can delete default phoenix css files

Where Next?

Trending in Questions Top

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
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
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