如何在弹出的create-react-app中添加预编译步骤?

时间:2018-09-13 17:20:28

标签: javascript typescript webpack compilation create-react-app

在标准弹出的create-react-app中,当您更改源代码文件时,您会看到:

Compiling...
Compiled successfully!

我想要的是每次修改文件(理想情况下具有某个扩展名)时在编译步骤之前执行的自定义命令。 我尝试使用webpack-shell-plugin

plugins: [
    ...
    new WebpackShellPlugin({
        onBuildStart: ['echo "Starting"'],
    })
]

现在我明白了:

node run start

> webapp@0.1.0 prestart /path/to/a/webapp
> node scripts/start.js

Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
Watching: /path/to/a/webapp/src
Executing pre-build scripts
"Starting"
Starting the development server...

ts-loader: Using typescript@3.0.1 and /path/to/a/webapp/tsconfig.json
Compiled successfully!

You can now view webapp in the browser.

    Local:            http://localhost:3000/
    On Your Network:  http://192.168.2.159:3000/

Note that the development build is not optimized.
To create a production build, use npm run build.

Compiling...
Compiled successfully!
Compiling...
Compiled successfully!
Compiling...
Compiled successfully!

您会注意到,它在第一次编译之前只能运行一次,然后再也不会调用。

我应该将脚本挂接到另一个地方吗?还是其他插件?

0 个答案:

没有答案