0

I'm on Win10, and as you know, paths are a mess. I don't want to use backward slashes because that would make it too os-specific. I want to use "path", but I can't use it prior to imports.

import React from 'react';
import ReactDOM from 'react-dom';
var path = require("path");
var bootstrapCSS = path.normalize('./src/assets/bootstrap/css/bootstrap.min.css');
var fontCSS = path.normalize('./src/assets/font-awesome/css/font-awesome.min.css');
var seguiCSS = path.normalize('./src/assets/segui-info.css');
import bootstrapCSS
import fontCSS
import seguiCSS

How can I import normalized paths?

Ericson Willians
  • 7,606
  • 11
  • 63
  • 114
  • 1
    If you normalize a path and then export it. It will still be normalized when you import it to another file. – CascadiaJS Sep 26 '17 at 22:16
  • So, I should create a .js file exporting all my paths and import using from? – Ericson Willians Sep 26 '17 at 22:19
  • yes, that will work, but you have access to 'path' why not just require it and then normalize the paths the way you already are? – CascadiaJS Sep 26 '17 at 22:27
  • I tried to export them, but it treats them as mere variables instead of actually loading the CSS. The way I was doing does not work because it doesn't let me write code / normalize before importing. – Ericson Willians Sep 26 '17 at 22:36
  • I did some searching, ES6 import statements can't import CSS, but there are some libraries that can do this: https://stackoverflow.com/questions/24923479/can-es6s-module-loader-also-load-assets-html-css – CascadiaJS Sep 26 '17 at 22:48
  • Are those css libraries installed in your `node_modules`? – bntzio Sep 27 '17 at 02:23

0 Answers0