Comments (10)
if you want to use React Typescript in the current version (0.0.1) you can pass a full custom setup, without specifying the template prop. There's an example in storybook: https://github.com/codesandbox/sandpack/blob/main/sandpack-react/src/presets/Sandpack.stories.tsx#L83
You can also add a template, there's another issue with adding more templates, I will add react-typescript there on the list. But that's just a temporary implementation as we want to fetch the setup files from the codesandbox templates on the long term, so we don't keep these hardcoded versions of the files and dependencies.
from sandpack.
This did work for me, but I also got a bit confused. If I am not using any templates, what are the defaults for config files.
For example, say I wanted to add a custom webpack config file, what would be the best way to do that ?
from sandpack.
if no template
prop is passed, only the files in customSetup
are used, so whatever you pass there it will be used by the bundler. whatever works in codesandbox, should work here. not sure about webpack though, since the bundler is not using it. what is the webpack config solving in your case?
from sandpack.
I wanted to integrate react-native-vector-icons
in a react-native-web
project. The package has support for icons on web, but requires to do some config https://github.com/oblador/react-native-vector-icons#examples
In your webpack configuration file, add a section to handle ttf files using url-loader (or file-loader)
{
test: /\.ttf$/,
loader: "url-loader", // or directly file-loader
include: path.resolve(__dirname, "node_modules/react-native-vector-icons"),
},
from sandpack.
Hey @alexnm, do you have any recommendation on what would be the best way to do this ?
from sandpack.
So it's a bit tricky with this, because the bundler can run loaders, but does not read a webpack config, if you look at the bundler code in codesandbox-client/packages/app/src/sandbox
you can what's happening. I'm not that familiar with that side of the codebase, but from what I talked with Ives, the bundler was not build to run custom loaders because then you project would not work when you download it locally. I'll keep this open to see if we can come up with a partial solution for sandpack only.
from sandpack.
https://codesandbox.io/s/30x4zovko1
This example is using custom webpack config files and these are working fine, as an alternative setup to create-react-app
from sandpack.
🤷♂️
🤷♂️ 🤷♂️
🤷♂️ 🤷♂️ 🤷♂️
🤷♂️ 🤷♂️ 🤷♂️ 🤷♂️
I am so confused 🤣
from sandpack.
have you tried passing webpack configs in a similar manner with the codesandbox link? so webpack is not actually running in the bundler, but there's a CLI used to run the webpack loaders during the bundling/transpile process. In theory, if you pass all the files that this codesandbox has to a sandpack instance, it should run in the same way
from sandpack.
I'll close this and move the topic of templates to a discussion here on github
from sandpack.
Related Issues (20)
- Update Next.js template and node version to suport next.js app router template HOT 1
- Prioritization error regarding custom style
- Failed to get shell by ID
- Is it possible to load local files HOT 2
- Throw a string in SandpackTests will make the component crash
- Page becomes unresponsive HOT 4
- How to "host" the app HOT 2
- Invalid left-hand side in assignment HOT 1
- Full Reset on any state changes in React Codesandbox HOT 1
- %c%s & color: rgba(125, 125, 125, 0.5) in console.log <Sandpack/> (strictMode?) HOT 1
- Changing decorators recreates Codemirror HOT 1
- ts-node template HOT 1
- Broken example with Sandpack Console HOT 1
- Documentation: Sandpack Layout does not accept a theme prop. But the docs says it does. Also the link is broken showing the example. HOT 3
- Broken Korean text in sandpack-react test error messages
- Custom Jest asymmetric matchers break in SandpackTests HOT 1
- Documentation: Hosting the Bundler HOT 2
- bee
- support images
- add react-vite and react-vite-ts to template definition HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sandpack.