简体   繁体   中英

How to handle variable replacement in dev vs rollup build?

I am making a site that was based off Open Web Components Generator .

I hit the same issue of process not being defined for redux as this SO question:

lit-element with rollup and redux: process is not defined

I am confused because the top answer says to use Rollup's replace plugin. This works great for the built version from the generator's package.json which runs the following:

"build": "rimraf dist && tsc && rollup -c rollup.config.js && npm run analyze -- --exclude dist",

However when I'm just doing dev watcher the command is this:

"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\""

Rollup isn't going to run while just doing a dev watcher like this so I'm not sure how to solve the problem when doing dev as opposed to building.

Meanwhile the Redux maintainer on the original post, says to use an artifact when not bundling with something via Rollup.

My code is like the following so I'm not sure how to satisfy both conditions.

import {
  configureStore,
  EnhancedStore,
} from '@reduxjs/toolkit';

I wonder if this is an issue on me, or Open WC not using Rollup watch under the hood?

If you don't want to build for dev, and you are still waiting for packages to stop assuming that you are, the simplest answer is to just define window.process in one of your files. This isn't a great answer, but it's what I've done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM