我在使用 typescript 和 webpack 2 配置文件的语法时遇到问题:
等效的javascript是:
switch (process.env.BUILD_ENV) {
case 'live':
module.exports = require('./config/webpack.live');
break;
case 'debug':
module.exports = require('./config/webpack.debug');
break;
default:
module.exports = require('./config/webpack.doesntexist');
}
Webpack 2 需要一个 TS 配置文件,所以我尝试将此部分更改为:
switch (process.env.BUILD_ENV) {
case 'live':
export * from './config/webpack.live';
break;
case 'debug':
export * from './config/webpack.debug';
break;
default:
export * from './config/webpack.doesntexist';
}
我收到错误消息:“导出声明只能在模块中使用”。但我不清楚这意味着什么。我怎样才能在打字稿中更正这个?或者这不是在 webpack 2 中构建配置的方式吗?