chore: fix watch scripts
This commit is contained in:
parent
f0c7f90c46
commit
46faa98b34
3 changed files with 25 additions and 13 deletions
13
package.json
13
package.json
|
|
@ -20,14 +20,13 @@
|
|||
"unpkg": "dist/umd/index.js",
|
||||
"jsdelivr": "dist/umd/index.js",
|
||||
"scripts": {
|
||||
"build": "yarn build:clean && yarn build:umd && yarn build:esm",
|
||||
"build:esm": "babel src --root-mode upward --extensions '.ts,.tsx' --out-dir dist/esm",
|
||||
"build:esm:watch": "yarn build:esm --watch",
|
||||
"build:umd": "rollup --config",
|
||||
"build:types": "tsc -p ./tsconfig.declaration.json --outDir ./dist/esm",
|
||||
"build:types:watch": "chokidar \"**/*.ts\" \"**/*.tsx\" --command \"yarn build:types\" --ignore \"dist\"",
|
||||
"build": "yarn build:clean && yarn build:umd && yarn build:esm && yarn build:types",
|
||||
"build:umd": "BUILD=umd rollup --config",
|
||||
"build:esm": "BUILD=esm rollup --config",
|
||||
"build:types": "tsc -p ./tsconfig.declaration.json --outFile ./dist/esm/index.d.ts",
|
||||
"build:clean": "rm -rf ./dist",
|
||||
"watch": "concurrently \"yarn build:esm:watch\" \"yarn build:types:watch\""
|
||||
"on:change": "concurrently \"yarn build:esm\" \"yarn build:types\"",
|
||||
"watch": "watch \"yarn on:change\" --ignoreDirectoryPattern \"/dist/\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@docsearch/react": "^1.0.0-alpha.23",
|
||||
|
|
|
|||
|
|
@ -1,12 +1,25 @@
|
|||
import { plugins } from '../../rollup.base.config';
|
||||
|
||||
export default {
|
||||
input: 'src/index.ts',
|
||||
output: {
|
||||
if (!process.env.BUILD) {
|
||||
throw new Error('The `BUILD` environment variable is required to build.');
|
||||
}
|
||||
|
||||
const output = {
|
||||
umd: {
|
||||
file: 'dist/umd/index.js',
|
||||
format: 'umd',
|
||||
sourcemap: true,
|
||||
name: 'docsearch',
|
||||
},
|
||||
esm: {
|
||||
file: 'dist/esm/index.js',
|
||||
format: 'es',
|
||||
sourcemap: true,
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
input: 'src/index.ts',
|
||||
output: output[process.env.BUILD],
|
||||
plugins,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { DocSearch, version } from '@docsearch/react';
|
||||
import { DocSearch, DocSearchProps, version } from '@docsearch/react';
|
||||
import React, { render } from 'preact/compat';
|
||||
|
||||
function getHTMLElement(
|
||||
value: string | HTMLElement,
|
||||
environment: typeof window = window
|
||||
environment: DocSearchProps['environment'] = window
|
||||
): HTMLElement {
|
||||
if (typeof value === 'string') {
|
||||
return environment.document.querySelector<HTMLElement>(value)!;
|
||||
|
|
@ -12,7 +12,7 @@ function getHTMLElement(
|
|||
return value;
|
||||
}
|
||||
|
||||
export function docsearch(props) {
|
||||
export function docsearch(props: DocSearchProps) {
|
||||
render(
|
||||
<DocSearch
|
||||
{...props}
|
||||
|
|
|
|||
Loading…
Reference in a new issue