我正在搞乱打字稿+ webpack。我使用webpack重新编译typescript" test.ts"每次保存的代码。该脚本编译为dist / scripts / main.js
当我运行node ./dist/scripts/main.js
时,我可以看到我脚本的控制台输出。
每次webpack重新编译脚本时,是否可以运行此命令?
谢谢。
这是我的webpack配置:
/* eslint-disable no-var, strict, prefer-arrow-callback */
'use strict';
var path = require('path');
module.exports = {
cache: true,
watch: true,
entry: {
main: './test.ts',
vendor: [
'babel-polyfill'
]
},
output: {
path: path.resolve(__dirname, './dist/scripts'),
filename: '[name].js',
chunkFilename: '[chunkhash].js'
},
module: {
loaders: [{
test: /\.ts(x?)$/,
exclude: /node_modules/,
loader: 'babel-loader?presets[]=es2015!ts-loader'
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015']
}
}]
},
plugins: [
],
resolve: {
extensions: ['.ts', '.tsx', '.js']
}
};
答案 0 :(得分:1)
将此行添加到package.json:
...
"scripts": {
"start": "npm run dev",
"webpack": "webpack --progress --colors",
"dev": "webpack-dev-server --devtool eval --progress --colors --inline"
},
...
并在运行您的应用后npm start