aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/ts/ts_vite.conf
blob: 04ee37227ebea578f45bdb419188bb077f3b8690 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
VITE_OUTPUT_DIR=dist
VITE_CONFIG_PATH=vite.config.ts

TS_VITE_CMD=$TOUCH_UNIT \
    && $_TS_FILES_COPY_CMD \
    && $ADD_VCS_INFO_FILE_CMD \
    && $NOTS_TOOL $NOTS_TOOL_BASE_ARGS build-vite $NOTS_TOOL_COMMON_BUILDER_ARGS \
      --bundler-config-path ${input:VITE_CONFIG_PATH} \
      --output-dir ${VITE_OUTPUT_DIR} \
    $_NODE_MODULES_INOUTS ${hide:PEERS} \
    ${input;hide:"package.json"} ${TS_CONFIG_FILES} $_AS_HIDDEN_INPUTS(IN $TS_INPUT_FILES) \
    ${output;hide:"package.json"} \
    ${kv;hide:"pc magenta"} ${kv;hide:"p TS_VIT"}

### @usage: VITE_OUTPUT(DirName)
###
### Macro sets the output directory name for TS_VITE module.
###
### - DirName - output directory name ("dist" by default).
macro VITE_OUTPUT(DirName) {
    SET(VITE_OUTPUT_DIR $DirName)
}

### @usage: TS_VITE([name])
###
### The Vite bundle, bundles JavaScript code.
### Build results are packed as `output.tar`.
###
### @example
###
###     TS_VITE()
###     END()
###
multimodule TS_VITE {
    module BUILD: _TS_BASE_UNIT {
        .CMD=TS_VITE_CMD
        .EPILOGUE=_TS_CONFIG_EPILOGUE
        .PEERDIRSELF=TS_PREPARE_DEPS

        # by default multimodule overrides inherited MODULE_TAG to submodule name (BUILD in this case)
        # but we have to set it to TS for include processor to work
        SET(MODULE_TAG TS)

        _PEERDIR_TS_RESOURCE(vite)

        DISABLE(TS_CONFIG_DEDUCE_OUT)
        DISABLE(TS_CONFIG_USE_OUTDIR)

        _TS_CONFIGURE($TS_CONFIG_PATH)

        SET_APPEND(_MAKEFILE_INCLUDE_LIKE_DEPS ${CURDIR}/package.json ${CURDIR}/pnpm-lock.yaml ${CURDIR}/${TS_CONFIG_PATH})
        _TS_ADD_NODE_MODULES_FOR_BUILDER()
    }

    module TS_PREPARE_DEPS: _PREPARE_DEPS_BASE {

    }
}