Code Monkey home page Code Monkey logo

remix-webpack-demo's Introduction

Remix Webpack Demo

This is an example of using Webpack as the compiler for a Remix app. While not supported as a long-term solution, we offer this example as a migration path for your React Router / Webpack apps to Remix.

To migrate your Webpack-based React Router app, check out the migration guide. ๐Ÿ‘€


How this repo was made:

  1. Create a new project with Create React App
  2. ๐Ÿ‘‰ Implement the React Router v6.4 tutorial
  3. ๐Ÿšš Migrate to Remix
  4. Replace standard Remix dev tools with Webpack-based compiler found in ./scripts

The commit history includes ๐Ÿ‘‰ and ๐Ÿšš emojis so you can follow along with which commits came from which step.

Setup

1 Install

npm install

2 .env

Copy .env.example as .env:

DATABASE_URL="file:./dev.db"

3 Initialize the database

npx prisma db push

If you want some data for development, seed the database:

npx prisma db seed

4 Run the app

# development
npm run dev

# production build
npm run build
npm start

Configuration

Webpack configs can be found at:

You can add loaders or plugins there to add support for any features you'd like from Webpack!

For example, you could install postcss-loader and add it to both the browser and server configs to get PostCSS features!

remix-webpack-demo's People

Contributors

mcansh avatar pawelblaszczyk5 avatar pcattori avatar ryanflorence avatar vsumner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

remix-webpack-demo's Issues

database instances on reloads

warn(prisma-client) There are already 10 instances of Prisma Client actively running.

need to do the silly global tricks we do in Remix stacks.

bug when run dev

Bug report

  • download demo
  • npm i cross-env
  • change script "dev": "cross-env NODE_ENV=development ts-node ./scripts/dev.ts"
  • npm run dev
Remix App Server started at http://localhost:3000 (http://10.1.1.104:3000)
emix-webpack-demo-mainappentry.server.tsx" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "e:" URIs.
    at E:\learn\remix-webpack-demo-main\node_modules\webpack\lib\NormalModule.js:832:25
    at Hook.eval [as callAsync] (eval at create (E:\learn\remix-webpack-demo-main\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (E:\learn\remix-webpack-demo-main\node_modules\tapable\lib\Hook.js:18:14)
    at Object.processResource (E:\learn\remix-webpack-demo-main\node_modules\webpack\lib\NormalModule.js:829:8)
    at processResource (E:\learn\remix-webpack-demo-main\node_modules\loader-runner\lib\LoaderRunner.js:220:11)
    at iteratePitchingLoaders (E:\learn\remix-webpack-demo-main\node_modules\loader-runner\lib\LoaderRunner.js:171:10)
    at runLoaders (E:\learn\remix-webpack-demo-main\node_modules\loader-runner\lib\LoaderRunner.js:398:2)
    at NormalModule._doBuild (E:\learn\remix-webpack-demo-main\node_modules\webpack\lib\NormalModule.js:819:3)
    at NormalModule.build (E:\learn\remix-webpack-demo-main\node_modules\webpack\lib\NormalModule.js:963:15)
    at E:\learn\remix-webpack-demo-main\node_modules\webpack\lib\Compilation.js:1371:12
    at Object.707 (E:\learn\remix-webpack-demo-main\build\index.js:191:7)
    at __webpack_require__ (E:\learn\remix-webpack-demo-main\build\index.js:215:41)
    at Object.44 (E:\learn\remix-webpack-demo-main\build\index.js:19:107)
    at __webpack_require__ (E:\learn\remix-webpack-demo-main\build\index.js:215:41)
    at E:\learn\remix-webpack-demo-main\build\index.js:278:85
    at E:\learn\remix-webpack-demo-main\build\index.js:282:3
    at Object.<anonymous> (E:\learn\remix-webpack-demo-main\build\index.js:287:12)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Module.m._compile (E:\learn\remix-webpack-demo-main\node_modules\ts-node\src\index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
GET / 500 - - 223.268 ms

feature: rspack & turbopack

rspack was recently released. Is there any advantages to using rspack over remix compiler? Now that rspack might replace webpack with subseconds?

feature request might be to support rspack. But it no advantages, please close this after replying.

every save logs a not found object

If you save a file, the terminal logs:

๐Ÿ’ฟ Rebuilt in 371ms
{ data: '', status: 404, statusText: 'Not Found' }

I can't find what is logging it.

Invalid URL when css use background image

Operating System: Macos 13.0
Node Version: v16.17.1
NPM Version: 8.19.2
webpack Version: 5.75.0
css-loader Version: 6.7.3

Bug report

css-loader cannot load css correctly when css use background-image in webpack5(use asset/resource)

Actual Behavior

originalExports /Users/mingchenhong/webpack5-css-loader-image-issue/src/main.module.css.webpack[javascript/auto]!=!/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/Users/mingchenhong/webpack5-css-loader-image-issue/src/main.module.css
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

HookWebpackError: Invalid URL
    at tryRunOrWebpackError (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/HookWebpackError.js:88:9)
    at __webpack_require_module__ (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:5058:12)
    at __webpack_require__ (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:5015:18)
    at /Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:5086:20
    at symbolIterator (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:3485:9)
    at done (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:3527:9)
    at Hook.eval [as callAsync] (eval at create (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:4993:43
    at symbolIterator (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:3482:9)
    at timesSync (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:2297:7)
-- inner error --
TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:387:5)
    at URL.onParseError (node:internal/url:564:9)
    at new URL (node:internal/url:640:5)
    at Module.<anonymous> (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/Users/mingchenhong/webpack5-css-loader-image-issue/src/main.module.css:15:37)
    at /Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/javascript/JavascriptModulesPlugin.js:441:11
    at Hook.eval [as call] (eval at create (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
    at /Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:5060:39
    at tryRunOrWebpackError (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/HookWebpackError.js:83:7)
    at __webpack_require_module__ (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:5058:12)
    at __webpack_require__ (/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/webpack/lib/Compilation.js:5015:18)

Generated code for /Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/Users/mingchenhong/webpack5-css-loader-image-issue/src/main.module.css
 1 | __webpack_require__.r(__webpack_exports__);
 2 | /* harmony export */ __webpack_require__.d(__webpack_exports__, {
 3 | /* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
 4 | /* harmony export */ });
 5 | /* harmony import */ var _node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/runtime/noSourceMaps.js */ "/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/runtime/noSourceMaps.js");
 6 | /* harmony import */ var _node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
 7 | /* harmony import */ var _node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/runtime/api.js */ "/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/runtime/api.js");
 8 | /* harmony import */ var _node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
 9 | /* harmony import */ var _node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/runtime/getUrl.js */ "/Users/mingchenhong/webpack5-css-loader-image-issue/node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/runtime/getUrl.js");
10 | /* harmony import */ var _node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2__);
11 | // Imports
12 |
13 |
14 |
15 | var ___CSS_LOADER_URL_IMPORT_0___ = new URL(/* asset import */ __webpack_require__(/*! ./images/bg.png */ "asset|/Users/mingchenhong/webpack5-css-loader-image-issue/src/images/bg.png"), __webpack_require__.b);
16 | var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
17 | var ___CSS_LOADER_URL_REPLACEMENT_0___ = _node_modules_pnpm_css_loader_6_7_3_webpack_5_75_0_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(___CSS_LOADER_URL_IMPORT_0___);
18 | // Module
19 | ___CSS_LOADER_EXPORT___.push([module.id, ".f48igO_1iEJpmCDN3AjE {\n  color: red;\n  background-image: url(" + ___CSS_LOADER_URL_REPLACEMENT_0___ + ");\n}", ""]);
20 | // Exports
21 | ___CSS_LOADER_EXPORT___.locals = {
22 | 	"container": "f48igO_1iEJpmCDN3AjE"
23 | };
24 | /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
25 |  {

Expected Behavior

Javascript can import css that contain background-image and url will be transform to public path.

How Do We Reproduce?

https://github.com/Jerry-Hong/webpack5-css-loader-image-issue

npm i
npm run build

Please paste the results of npx webpack-cli info here, and mention other relevant information

System:
OS: macOS 13.0
CPU: (8) arm64 Apple M2
Memory: 44.70 MB / 16.00 GB
Binaries:
Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.1/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v16.17.1/bin/npm
Browsers:
Brave Browser: 106.1.44.105
Safari: 16.1
Packages:
css-loader: ^6.7.3 => 6.7.3
esbuild-loader: ^2.20.0 => 2.20.0
webpack: ^5.75.0 => 5.75.0
webpack-cli: ^5.0.1 => 5.0.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.