更新打包设置
This commit is contained in:
parent
c99f7f8149
commit
2ef48e17c6
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -8,7 +8,7 @@
|
|||||||
"type": "chrome",
|
"type": "chrome",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "启动 Chrome 并打开 localhost",
|
"name": "启动 Chrome 并打开 localhost",
|
||||||
"url": "http://localhost:666",
|
"url": "http://localhost:7776",
|
||||||
"webRoot": "${workspaceFolder}"
|
"webRoot": "${workspaceFolder}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
38
config/webpack.common.ts
Normal file
38
config/webpack.common.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import * as path from 'path';
|
||||||
|
import * as webpack from 'webpack';
|
||||||
|
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||||
|
import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
|
||||||
|
|
||||||
|
const config: webpack.Configuration = {
|
||||||
|
devtool: "source-map",
|
||||||
|
//项目需要解析的文件拓展名称
|
||||||
|
resolve: {
|
||||||
|
extensions: [".ts", ".tsx", ".js", "json"]
|
||||||
|
},
|
||||||
|
externals: {
|
||||||
|
'three': "THREE"
|
||||||
|
},
|
||||||
|
//模块加载器设置
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: 'ts-loader',
|
||||||
|
options: {
|
||||||
|
transpileOnly: true,
|
||||||
|
experimentalWatchApi: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
|
||||||
|
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
new HardSourceWebpackPlugin(),
|
||||||
|
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default config;
|
@ -1,47 +1,21 @@
|
|||||||
import * as path from 'path';
|
|
||||||
import * as webpack from 'webpack';
|
import * as webpack from 'webpack';
|
||||||
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
import * as merge from 'webpack-merge';
|
||||||
import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
|
import common from './webpack.common';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
const config: webpack.Configuration = {
|
const config: webpack.Configuration = merge(
|
||||||
mode: "production",
|
common,
|
||||||
entry: "./src/index.ts",
|
{
|
||||||
devtool: "source-map",
|
mode: "production",
|
||||||
//输出设置
|
entry: "../src/index.ts",
|
||||||
output: {
|
//输出设置
|
||||||
filename: "cad.js",
|
output: {
|
||||||
path: path.resolve(__dirname, '../umd'),
|
filename: "cad.js",
|
||||||
library: "cad",
|
path: path.resolve(__dirname, '../umd'),
|
||||||
libraryTarget: "umd"
|
library: "cad",
|
||||||
},
|
libraryTarget: "umd"
|
||||||
//项目需要解析的文件拓展名称
|
},
|
||||||
resolve: {
|
}
|
||||||
extensions: [".ts", ".tsx", ".js", "json"]
|
);
|
||||||
},
|
|
||||||
externals: {
|
|
||||||
'three': "THREE"
|
|
||||||
},
|
|
||||||
//模块加载器设置
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.tsx?$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader: 'ts-loader',
|
|
||||||
options: {
|
|
||||||
transpileOnly: true,
|
|
||||||
experimentalWatchApi: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ test: /\.css$/, loader: ['style-loader', 'css-loader'] },
|
|
||||||
{ test: /\.[(jpg)|(png)|(obj)|(json)]$/, loader: "url-loader" },
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
plugins: [
|
|
||||||
new HardSourceWebpackPlugin(),
|
|
||||||
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
35
config/webpack.view.ts
Normal file
35
config/webpack.view.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import * as webpack from 'webpack';
|
||||||
|
import * as merge from 'webpack-merge';
|
||||||
|
import common from './webpack.umd';
|
||||||
|
import * as HtmlWebPackPlugin from "html-webpack-plugin";
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
function getpath(fileName)
|
||||||
|
{
|
||||||
|
return path.resolve(__dirname, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
const config: webpack.Configuration = merge(
|
||||||
|
common,
|
||||||
|
{
|
||||||
|
mode: "development",
|
||||||
|
entry: "./src/ViewSrc/index.ts",
|
||||||
|
output: { pathinfo: false },
|
||||||
|
devtool: "cheap-module-eval-source-map",
|
||||||
|
devServer: {
|
||||||
|
contentBase: "./dist/",
|
||||||
|
port: 7776,
|
||||||
|
hot: true
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// new webpack.NamedModulesPlugin(),//Hot
|
||||||
|
// new webpack.HotModuleReplacementPlugin(),//Hot
|
||||||
|
new HtmlWebPackPlugin({
|
||||||
|
title: "webCAD",
|
||||||
|
// template: getpath('../src/index.html')
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export default config;
|
2148
package-lock.json
generated
2148
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -8,7 +8,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"umd": "webpack --config ./config/webpack.umd.ts",
|
"umd": "webpack --config ./config/webpack.umd.ts",
|
||||||
"dev": "tsc -w",
|
"dev": "webpack-dev-server --config ./config/webpack.view.ts",
|
||||||
"type": "ts-node ./utils/copy_type.ts"
|
"type": "ts-node ./utils/copy_type.ts"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -23,18 +23,24 @@
|
|||||||
"@types/three": "^0.92.17",
|
"@types/three": "^0.92.17",
|
||||||
"@types/uglifyjs-webpack-plugin": "^1.1.0",
|
"@types/uglifyjs-webpack-plugin": "^1.1.0",
|
||||||
"@types/webpack": "^4.4.10",
|
"@types/webpack": "^4.4.10",
|
||||||
|
"@types/webpack-dev-server": "^2.9.6",
|
||||||
|
"@types/webpack-env": "^1.13.6",
|
||||||
|
"@types/webpack-merge": "^4.1.3",
|
||||||
"awesome-typescript-loader": "^5.2.0",
|
"awesome-typescript-loader": "^5.2.0",
|
||||||
"fork-ts-checker-webpack-plugin": "^0.4.8",
|
"fork-ts-checker-webpack-plugin": "^0.4.8",
|
||||||
"hard-source-webpack-plugin": "^0.12.0",
|
"hard-source-webpack-plugin": "^0.12.0",
|
||||||
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"ts-loader": "^4.4.2",
|
"ts-loader": "^4.4.2",
|
||||||
"ts-node": "^7.0.1",
|
"ts-node": "^7.0.1",
|
||||||
"typescript": "^3.0.1",
|
"typescript": "^3.0.1",
|
||||||
"uglifyjs-webpack-plugin": "^1.3.0",
|
"uglifyjs-webpack-plugin": "^1.3.0",
|
||||||
"webpack": "^4.16.5",
|
"webpack": "^4.16.5",
|
||||||
"webpack-cli": "^3.1.0",
|
"webpack-cli": "^3.1.0",
|
||||||
|
"webpack-dev-server": "^3.1.5",
|
||||||
"webpack-merge": "^4.1.4"
|
"webpack-merge": "^4.1.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"three": "^0.95.0"
|
"three": "^0.95.0",
|
||||||
|
"wolfy87-eventemitter": "^5.2.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
src/ViewSrc/index.ts
Normal file
41
src/ViewSrc/index.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// import { Color, Face3, MeshBasicMaterial, Object3D, Vector2, Vector3 } from "three";
|
||||||
|
// import "./style.css";
|
||||||
|
import { data } from "../data";
|
||||||
|
import { Viewer } from "../Viewer";
|
||||||
|
import { CameraControlState } from "../CameraControls";
|
||||||
|
import { LoadBoard } from "../Utils";
|
||||||
|
|
||||||
|
let btn = document.createElement("button");
|
||||||
|
btn.innerHTML = "载入"
|
||||||
|
document.body.appendChild(btn);
|
||||||
|
|
||||||
|
let btn2 = document.createElement("button");
|
||||||
|
btn2.innerHTML = "清理"
|
||||||
|
document.body.appendChild(btn2);
|
||||||
|
|
||||||
|
let el = document.createElement("canvas");
|
||||||
|
|
||||||
|
el.style.width = "80%";
|
||||||
|
el.style.height = "80%";
|
||||||
|
document.body.appendChild(el);
|
||||||
|
|
||||||
|
let view = new Viewer(el);
|
||||||
|
|
||||||
|
//修改这个顺序 改变1 2 3 个触摸点时的触发状态.
|
||||||
|
view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Rotate, CameraControlState.Scale, CameraControlState.Pan];
|
||||||
|
//例如,修改单指滑动为平移.
|
||||||
|
view.m_CameraCtrl.m_TouthTypeList = [CameraControlState.Pan, CameraControlState.Scale, CameraControlState.Rotate];
|
||||||
|
|
||||||
|
//加载
|
||||||
|
btn.onclick = () =>
|
||||||
|
{
|
||||||
|
console.time();
|
||||||
|
for (let i = 0; i < 1; i++)
|
||||||
|
LoadBoard(view, data);
|
||||||
|
console.timeEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
btn2.onclick = () =>
|
||||||
|
{
|
||||||
|
// LoadBoard(view, []);
|
||||||
|
}
|
@ -11,6 +11,8 @@
|
|||||||
],
|
],
|
||||||
"types": [
|
"types": [
|
||||||
"node",
|
"node",
|
||||||
|
"webpack-env",
|
||||||
|
"webpack-dev-server"
|
||||||
],
|
],
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"experimentalDecorators": true
|
"experimentalDecorators": true
|
||||||
|
Loading…
Reference in New Issue
Block a user