direflow icon indicating copy to clipboard operation
direflow copied to clipboard

[Question] How to load external CSS from a node_moodules package

Open arthurhamon opened this issue 4 years ago • 1 comments

Hi and thank you for the help.

I have installed an external package, for example @name/my-package.

How can I load the css from this package using external-loader ?

I've tried to do it like this but its not working.

"plugins": [
      {
        "name": "external-loader",
        "options": {
          "paths": [
            "~@name/my-package/style.css"
          ]
        }
      }
    ]

arthurhamon avatar Aug 17 '21 15:08 arthurhamon

If i understand your question properly, You should be able to include css files by directly importing them in your direflow components. Filename : direflow-components/index.js

import "@name/my-package/style.css";

if you want to add additional loaders for the css file type, add webpack config for direflow, Filename : direflow-webpack.js

                      module.exports = (config, env) => ({
                      ...webpackConfig(config, env),
                      module: {
                        rules: [
                          {
                            test: /\.(sa|sc|c)ss$/,
                            loader: ["style-loader", "css-loader", "sass-loader"],
                          },
                        ],
                      },
                      // Add your own webpack config here (optional)
                    });

vijay122 avatar Feb 06 '22 14:02 vijay122