74 lines
2.0 KiB
TypeScript
74 lines
2.0 KiB
TypeScript
![]() |
const webpack = require('webpack');
|
||
|
const path = require('path');
|
||
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||
|
|
||
|
function getpath(fileName)
|
||
|
{
|
||
|
return path.resolve(__dirname, fileName);
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
//项目入口
|
||
|
entry: "./src/index.ts",
|
||
|
//输出设置
|
||
|
output: {
|
||
|
filename: "cad.js",
|
||
|
path: path.resolve(__dirname, 'umd'),
|
||
|
library: {
|
||
|
// root: "cadview",
|
||
|
// amd: "cadview",
|
||
|
commonjs: "cad"
|
||
|
},
|
||
|
libraryTarget: "umd"
|
||
|
},
|
||
|
//调试工具
|
||
|
// devtool: "source-map",
|
||
|
//项目需要解析的文件拓展名称
|
||
|
resolve: {
|
||
|
extensions: [".ts", ".tsx", ".js", "json"]
|
||
|
},
|
||
|
|
||
|
externals: {
|
||
|
'three': {
|
||
|
// amd: 'three',
|
||
|
commonjs: 'three',
|
||
|
root: "THREE",
|
||
|
commonjs2: "three"
|
||
|
},
|
||
|
},
|
||
|
//模块加载器设置
|
||
|
module: {
|
||
|
loaders: [
|
||
|
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
|
||
|
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
|
||
|
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
|
||
|
]
|
||
|
},
|
||
|
//插件
|
||
|
plugins: [
|
||
|
new webpack.DefinePlugin({
|
||
|
'process.env.NODE_ENV': JSON.stringify('production')
|
||
|
}),
|
||
|
new UglifyJsPlugin(
|
||
|
{
|
||
|
uglifyOptions:
|
||
|
{
|
||
|
compress: {
|
||
|
warnings: false,
|
||
|
conditionals: true,
|
||
|
unused: true,
|
||
|
comparisons: true,
|
||
|
sequences: true,
|
||
|
dead_code: true,
|
||
|
evaluate: true,
|
||
|
if_return: true,
|
||
|
join_vars: true
|
||
|
},
|
||
|
output: {
|
||
|
comments: false
|
||
|
}
|
||
|
}
|
||
|
}),
|
||
|
]
|
||
|
}
|