Closed sandangel closed 7 years ago
Hi @sandangel, how did you solve it?
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'
})
]
mine is doesnt work :(
import vue from 'rollup-plugin-vue';
import typescript from 'rollup-plugin-typescript';
import scss from 'rollup-plugin-scss';
import commonjs from 'rollup-plugin-commonjs';
import {terser} from "rollup-plugin-terser";
import tildeImporter from 'node-sass-tilde-importer';
export default {
input: 'src/main.ts',
output: {
format: 'esm',
file: 'dist/main.js',
globals: {
'vue': 'Vue',
'vue-class-component ': 'vueClassComponent',
'query-string': 'queryString'
},
},
external: ['vue'],
plugins: [
vue(),
scss({
"includePaths": [
'./node_modules'
],
"importer": tildeImporter,
"output": 'dist/main.css'
}),
typescript(),
commonjs(),
terser()
]
}
+1
It'd be great if @import "~alias"
worked out of the bow with this plugin.
Have you tried with @rollup/plugin-alias ?
@rollup/plugin-alias
works for JS aliases but doesn't resolve SCSS aliases.
I still meet this issue so far ? Any suggest ?
@datnguyen-nfq , I'm using this simple importer:
import { resolve } from 'path'
import sass from 'sass'
const importer = (url, _prev, done) => {
if (url[0] !== '~') {
return null
}
const info = { file: resolve(`node_modules/${url.substr(1)}`) }
if (done) {
done(info)
}
return info
}
// Then, in the plugins section:
// ...
// scss({
// importer,
// sass,
// }),
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