question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to make @import "~bootstrap/scss/bootstrap" work?

See original GitHub issue

In main.js I have import a style.scss file, and in style.scss, I use @import “~bootstrap/scss/bootstrap” like I often do with webpack but rollup doesnot understand ~ sign is node_modules folder this is my rollup.config.js

import alias from 'rollup-plugin-alias'
import vue from 'rollup-plugin-vue'
import buble from 'rollup-plugin-buble'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import nodeGlobals from 'rollup-plugin-node-globals'
import butternut from 'rollup-plugin-butternut'
import livereload from 'rollup-plugin-livereload'
import serve from 'rollup-plugin-serve'
import scss from 'rollup-plugin-scss'

const plugins = [
  alias({
    vue$: 'vue/dist/vue.common.js'
  }),
  vue({
    autoStyles: false,
    styleToImports: true
  }),
  scss({
    output: 'public/assets/css/app.css',
    includePaths: [
      './node_modules'
    ]
  }),
  buble({
    objectAssign: 'Object.assign'
  }),
  nodeResolve({
    jsnext: true,
    main: true,
    browser: true
  }),
  commonjs(),
  nodeGlobals()
]

const config = {
  input: './src/main.js',
  output: {
    file: './public/assets/js/app.js',
    format: 'es'
  },
  sourcemap: 'inline',
  plugins: plugins
}

const isProduction = process.env.NODE_ENV === `production`
const isDevelopment = process.env.NODE_ENV === `development`

if (isProduction) {
  config.sourceMap = false
  config.plugins.push(butternut())
}

if (isDevelopment) {
  config.plugins.push(livereload())
  config.plugins.push(serve({
    contentBase: './public/',
    port: 8080,
    open: true
  }))
}

export default config

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
datnguyen-nfqcommented, Dec 9, 2020

I still meet this issue so far ? Any suggest ?

3reactions
OLmitchcommented, Jul 4, 2018

I’ve run into this exact same issue. Can rollup-plugin-scss support the ~ or not?

Update: Tilde’s seem to load properly when I use the node-sass-tilde-importer:

import tildeImporter from 'node-sass-tilde-importer';

plugins: [
  scss({
    importer: tildeImporter,
    output: 'dist/styles.css'
  })
]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sass · Bootstrap v5.0
In your custom.scss , you'll import Bootstrap's source Sass files. You have two options: include all of Bootstrap, or pick the parts you...
Read more >
How do I import bootstrap-sass once and use it in several files?
The way to import an SCSS file is to use that import command inside the parent SCSS file at the top. So if...
Read more >
Learn Bootstrap 5 and SASS by Building a Portfolio Website
Learn Bootstrap 5 and Sass by building a portfolio website. Bootstrap is one of the most popular CSS frameworks and Sass is one...
Read more >
Getting Started with Bootstrap 5, React, and Sass - Designmodo
Get React JS and Bootstrap 5 install and integrate together using npm. Setup Sass for different screen resolutions of your app.
Read more >
10 Most Common Bootstrap Mistakes That Developers Make
Don't know LESS or SASS? No problem, you can create your own CSS file and overwrite whatever you want from the original bootstrap.css...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found