Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
Compiling A Typescript Create React App to Import in another React App

I have a Create React App written in Typescript, I will call it MyApp. I want to run this App inside an already existing React App, I will call it ExistingApp.

I would like to use it as follows:

import App from "node_modules/@MyApp/src"

function ExistingApp() {
   return (
     <div className="App">
       <App />
     </div>
   );
}

export default ExistingApp;

I would like to do this compilation/Transpiling using Webpack. I would like the folder structure to be maintained without bundling everything into a single JS file. I have managed to achieve the desire outcome with

tsc --module commonjs --outDir dist

However my .scss files are not being copied to the dist folder. the dist folder only contains the transpilled js files.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The below solution is to get webpack to use Sass, with bundling. If you do not want bundling, I wouldn't use webpack at all.

In production, try:

  1. Install these packages with the following command
npm i --save-dev sass-loader node-sass mini-css-extract-plugin css-loader style-loader
  1. Add the following code snippet to your webpack config in the rules array (make sure to import MiniCssExtractPlugin in the config file)
{
     test: /\.(s(a|c)ss)$/,
     use: [MiniCssExtractPlugin.loader,'css-loader', 'sass-loader']
}

Import MiniCssExtractPlugin (put this at the top of the config):

import * as MiniCssExtractPlugin from "mini-css-extract-plugin"

OR

const MiniCssExtractPlugin = require("mini-css-extract-plugin")

In development, you can just do this

  1. Same thing as step one in example 1
  2. Use this code snippet instead, in the same place as example 1 (no need to import MiniCssExtractPlugin)
{
    test: /\.(s(a|c)ss)$/,
    use: ['style-loader','css-loader', 'sass-loader']
}

Source

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!