I want to use some node_modules in my Symfony 6 project. For example, Feather icons. But I can't figure out how to include these files without copying them to the public folder or using a CDN.
I have attempted to import the files into app.js using:
import './feather';
Sadly, this does not appear to work. Can anyone help me figure this out because I can also not find any relevant google search results.
EDIT
This is what my app.js currently looks like:
import './styles/app.css';
// start the Stimulus application
import './bootstrap';
import feather from 'feather-icons'; // <-- added line from comment
Related
I'm using airflow, and I want to import some plugins for my dags
The problem get into the play: when I'm trying to use them, follow by:
from dags_folder.plugins import fetchingData
I get this error
Module name "dags_folder" not found!
(here is my layout)
I've setting up with the airflow.cfg, but it doesn't work!
notes: I'm using conda-env
You need to add the folder dags_folder to python path:
export PYTHONPATH=${PYTHONPATH}:/path/to/dags_folder
then you could import fetchingData from plugins:
from plugins import fetchingData
(if you want to import it from dags_folder.plugins, you need to add the parent folder of dags_folder to the python path).
If you need this plugin in one module, you can add the plugins package to python path pragmatically:
import sys
sys.path.append("/path/to/dags_folder")
from plugins import fetchingData
So I have a app created with create react app with typescript. I have some components in a component folder and they have a file called .readme.md.
Now when I run storybook I se the readme part in the sidebar, but it says it can not find the readme file. If I in the storie file do a console.log on the Readme variable I import. I get the content from the readme.
My storybook/addons.js looks like this:
import 'storybook-readme/register';
Storybook dont allow me to have a config.js and a main.js. Now the storybook-readme documentations says I need to put the following code in config.js and it does not work to put in in main.js. Så where does this part go?
import { addReadme } from 'storybook-readme';
addDecorator(addReadme);
I am trying to import bootstrap.css file into my React component, but I am getting an error:
Module not found: Can't resolve '.../node_modules/bootstrap/dist/css/bootstrap.min.css' in '/Users/pavelsarygin/Desktop/programming_projects/excavate-main/excavate/client/src/components/Login/Signup'
Here is my folder structure:
folder structure
Can somebody please advise how to access the css file in node_modules folder from LoginForm.js component?
Thank you!
Try importing it like this:
import 'bootstrap/dist/css/bootstrap.min.css';
Triple dots import is invalid in webpack, and you should import bootstrap in your root component
To import any node_modules, just have relatively import like so:
import 'bootstrap'
Same when you want to import specifically some files inside that module:
import 'bootstrap/dist/css/bootstrap.min.css';
There are also a few other ways to import your bootstrap file which can be found here.
I have a React component and I publish the component in NPM registry that I build with webpack. In my main project I consumed the component npm package JS like that:
import myComp from 'myComp';
The problem is that myComp also has CSS, that I build into dist/index.css with the help of webpack and ExtractTextPlugin (which builds all the css into one file).
And I want to consume the style like this:
import 'myComp/index.css';
Or
import 'myComp/index';
And in myComp npm package I want to expose it in a way that will support this import method.
NOTE: I don't want to import it directly from node_modules
import '../../../node_modules/myComp/index.css'; // bad
Thanks!
So it's easier than I thought, all you need to do is import the CSS like that (as I did in the question):
import 'myComp/dist/style.css';
And make sure your tools (browserify/webpack etc..) can handle loading css into your javascript file.
So the issue was more related to the building process.
Also, if you want to push specific code into npm registry you can use "files" inside package.json. This way you'll end up with just the files you need in npm registry.
files: [
"dist/*.css"
]
You can also use tools like:
https://github.com/rotundasoftware/parcelify - for browserify
https://www.npmjs.com/package/parcelify-loader - for webpack
But I didn't like them. It forces a dependency on the consumer of your npm package.
I'm writing a client-side app that is using Webpack, and I cannot figure out how to require the materialize-css package. I'm using Henrik Joreteg's hjs-webpack package, and with this the yeticss npm package is included by doing an import in a sass file (e.g. #import 'yeticss'), but this doesn't work for materialize. Requiring it straight up in the code (e.g. import 'materialize-css' in a JS file) like any other package also doesn't work.
In this case, unlike with yeticss, you need to go in and require the specific files, rather than just the package name, thus:
import 'materialize-css/dist/css/materialize.min.css';
import 'materialize-css/dist/js/materialize.min';
In my case I'm using create-react-app, and I was able to execute:
yarn add materialize-css
And then in my index.js (top level react file):
import '../node_modules/materialize-css/dist/css/materialize.min.css';
import '../node_modules/materialize-css/dist/js/materialize.min';