もちろん、あなたはnpm install webpack --save-devを行っていることを前提にしています。これでnpm run build:testなどを実行できます。
この変数を使うのも簡単です:
/** * This interface makes sure we don't miss adding a property to both `prod` and `test` */interfaceConfig { someItem:string;}/** * We only export a single thing. The config. */exportlet config:Config;/** * `process.env.NODE_ENV` definition is driven from webpack * * The whole `else` block will be removed in the emitted JavaScript * for a production build */if (process.env.NODE_ENV==='production') { config = { someItem:'prod' }console.log('Running in prod');} else { config = { someItem:'test' }console.log('Running in test');}