0
我使用的是建立一個應用程序陣營+反應路由器+終極版+打字稿+的WebPack,這裏是我的tsconfig.json:陣營+反應路由器+打字稿的WebPack產品包問題
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es6",
"jsx": "react"
},
"files": [
"./src/index.tsx"
]
}
這是我的webpack.config.js樣子:
var PROD = JSON.parse(process.env.PROD_ENV || '0');
...
module.exports = {
...
plugins: PROD ? [
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
})
] : [],
...
module: {
loaders: [
// Sass loader for stylesheet.
{ test: /\.scss$/, loaders: ["style", "css", "sass"], exclude: /node_modules/ },
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{ test: /\.tsx?$/, loaders: ["babel-loader", "ts-loader"], exclude: /node_modules/ },
],
preLoaders: [
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ test: /\.js$/, loader: "source-map-loader" }
]
},
externals: {
"react": "React",
"react-dom": "ReactDOM",
"react-router": "ReactRouter",
"redux": "Redux",
"react-redux": "ReactRedux"
},
}
現在,如果我用的WebPack捆綁,一切都看起來不錯,但如果我跑
PROD_ENV=1 webpack
嘗試生成變醜JS束文件,它給了我下面的錯誤編譯消息:
ERROR in ./dist/bundle.js from UglifyJs
SyntaxError: Unexpected token: name (AppRoutes) [./src/routes.tsx:8,0]
任何幫助,將不勝感激!謝謝。
什麼是'。/ src/routes.tsx'看起來像? –