babel转换html失败,将babel换成typescript后的生产环境编译问题

尝试了下将es6直接换成typescript,但是会提示找不到@types react文件,虽然和课程的技术栈不太一样,但还是希望老师能帮我看看

tsconfig

{  "compilerOptions": {    "outDir": "./dist/",    "sourceMap": true,    "noImplicitAny": true,    "module": "commonjs",    "target": "es5",    "jsx": "react"

},  "include": [    "./src/**/*"

]

}

webpack.production.config.js

var path = require('path');var pkg = require('./package.json');var webpack = require('webpack');var HtmlWebpackPlugin = require('html-webpack-plugin');module.exports = {

entry: {

app: __dirname + '/src/index.tsx',

vendor: Object.keys(pkg.dependencies)

},

output: {

filename: "./js/[name].[hash].js",

path: __dirname + '/build'

},

resolve: {

extensions: [            '.ts', '.tsx', '.js', '.web', '.webpack.js', '.json'

]

},    module: {

rules: [

{test: /\.tsx?$/, loader: 'awesome-typescript-loader'},

{enforce: 'pre', test: /\.js$/, loader: 'source-map-loader'}

]

},

plugins: [        new HtmlWebpackPlugin({

template: path.resolve(__dirname, 'index.html')

}),        new webpack.HotModuleReplacementPlugin(),        new webpack.DefinePlugin({            'process.env': {                'NODE_ENV': JSON.stringify('production')

}

}),        new webpack.optimize.OccurrenceOrderPlugin(),        new webpack.optimize.UglifyJsPlugin({

compress: {

warnings: false

}

}),        new webpack.optimize.CommonsChunkPlugin({

name: 'vendor',

filename: './js/[name].[hash].js'

})

],

devServer: {

contentBase: './',

historyApiFallback: true,

inline: true,

hot: true

}

};

package.json

{  "name": "webpack-test3",  "version": "1.0.0",  "description": "",  "main": "index.js",  "scripts": {    "test": "echo \"Error: no test specified\" && exit 1",    "server": "webpack-dev-server --open",    "build":"webpack --progress --profile --config webpack.production.config.js"

},  "author": "",  "license": "ISC",  "devDependencies": {    "awesome-typescript-loader": "^3.2.3",    "html-webpack-plugin": "^2.30.1",    "source-map-loader": "^0.2.1",    "typescript": "^2.4.2",    "webpack": "^3.5.5",    "webpack-dev-server": "^2.7.1"

},  "dependencies": {    "@types/react": "^16.0.2",    "@types/react-dom": "^15.5.3",    "react": "^15.6.1",    "react-dom": "^15.6.1"

}

}

报错信息是

ERROR in multi @types/react @types/react-doom react react-dom

Module not found: Error: Can't resolve '@types/react' in ‘E:\webpack\webpack-test'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值