#webpack issues

65 messages · Page 1 of 1 (latest)

shut root
#

I searched the error and i need to add something in webpack config, but i'm not sure i did it right

#
module.exports = {
    entry: './src/index.js',
    module: {
        rules: [
            {
                test: /\.m?js/,
                type: "javascript/auto",
              },
              {
                test: /\.m?js/,
                resolve: {
                  fullySpecified: false,
                },
              },
        ],
    }
}```
dark dust
#

is this CRA?

shut root
#

CRA?

dark dust
#

create-react-app

shut root
#

yes

#

im using react

dark dust
#

using react does not equal using CRA

#

how did you create your initial app?

shut root
#

uh it was a template and i'm new to react so i am not sure but i'm using yarn

#

new = 1 month

#

i know how to create components and stuff

dark dust
#

what command did you run

shut root
#

it was a template so the files were already created but i don't have create-react-app in package.json

#

so it wasn't that

dark dust
#

it'd be react-scripts in package.json

shut root
#

oh then yes

dark dust
#

CRA should have automatically set up the webpack config properly

shut root
#

well the thing is initially it wasn't like that i've just changed it now

#

is there a command i could run

#

and it would configure it?

dark dust
#

if you're actually using CRA, you cannot add a webpack.config.js config like that. you have to eject first then modify everything. glhf after that, though...

#

but again, if you're actually using CRA, you shouldn't need to. it should already work.

shut root
#

i hhave react-scripts right there

#

and when i do

#

yarn start

#

to start the dev mode

#

it doesnt work

dark dust
#

attempting to run CRA to test, but as always it's taking forever. you should look into Vite

#

ya, you have something wrong

import reportWebVitals from './reportWebVitals';

no extension but it works just fine

shut root
#

yea if i remove the type: "module"

dark dust
#

ya, why would you even do that (add type:module)?

shut root
#

i want to use react-email

dark dust
#

and?

shut root
#

and in the backend i need to import

#

component

dark dust
#

react-scripts are the node script you're running. that has absolutely nothing to do with the browser app you're building

#

"backend" and CRA don't mix

shut root
#

how would i import the email.jsx tho (an example)

dark dust
#

in your react app...

shut root
#

but i need it in my backend

dark dust
#

dafaq?

#

you don't seem to understand client-side vs. server-side

shut root
#

i do

#

but i dont understand react-email

#

that's the problem

dark dust
#

email.tsx is an example of how you implement react-email, which is a client-side library.

shut root
#

yea but i use nodemailer to send emails

dark dust
shut root
#

yea they use import

dark dust
#

...

shut root
#

i cant use import with commonjs

dark dust
#

NONE OF THAT IS BACKEND CODE

shut root
#

no?

dark dust
#

it is all clearly React components, so no...

shut root
#

omg

#

i thought you could

#

send components

#

from client to backend

dark dust
#

...

shut root
#

im srry bruh