mirror of https://gitee.com/cf-fz/WebCAD.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
5.0 KiB
148 lines
5.0 KiB
import * as AddAssetHtmlPlugin from "add-asset-html-webpack-plugin";
|
|
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
import * as HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
|
|
import * as HtmlWebPackPlugin from "html-webpack-plugin";
|
|
import * as path from 'path';
|
|
import * as webpack from 'webpack';
|
|
import { outputDir } from "./outputPath";
|
|
|
|
function getpath(fileName)
|
|
{
|
|
return path.resolve(__dirname, fileName);
|
|
}
|
|
|
|
const config: webpack.Configuration = {
|
|
entry: "./src/index.tsx",
|
|
output: { path: getpath(outputDir) },
|
|
resolve: {
|
|
alias: {
|
|
"dat.gui": getpath('../node_modules/dat.gui/build/dat.gui.js'),
|
|
"three-FBXLoader": getpath("../src/Loader/FBXLoader.js"),
|
|
"three-CopyShader": getpath("../node_modules/three/examples/js/shaders/CopyShader.js"),
|
|
"three-SMAAShader": getpath("../node_modules/three/examples/js/shaders/SMAAShader.js"),
|
|
"three-FXAAShader": getpath("../node_modules/three/examples/js/shaders/FXAAShader.js"),
|
|
|
|
"three-OutlinePass": getpath("../src/GraphicsSystem/OutlinePass.js"),
|
|
"three-EffectComposer": getpath("../node_modules/three/examples/js/postprocessing/EffectComposer.js"),
|
|
"three-RenderPass": getpath("../node_modules/three/examples/js/postprocessing/RenderPass.js"),
|
|
"three-ShaderPass": getpath("../node_modules/three/examples/js/postprocessing/ShaderPass.js"),
|
|
"three-SMAAPass": getpath("../node_modules/three/examples/js/postprocessing/SMAAPass.js"),
|
|
},
|
|
extensions: [".ts", ".tsx", ".js", "json"]
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.tsx?$/,
|
|
exclude: /node_modules/,
|
|
loader: 'ts-loader',
|
|
options: {
|
|
transpileOnly: true,
|
|
experimentalWatchApi: true,
|
|
},
|
|
},
|
|
{
|
|
test: /\.[(png)|(obj)|(json)]$/,
|
|
loader: "file-loader"
|
|
},
|
|
//样式加载 css
|
|
{
|
|
test: /\.css$/,
|
|
use: ['style-loader', 'css-loader']
|
|
},
|
|
//样式加载 less
|
|
{
|
|
test: /\.less$/,
|
|
use: [{
|
|
loader: "style-loader"
|
|
},
|
|
{ loader: 'css-loader', options: { sourceMap: false } },
|
|
{
|
|
loader: "less-loader",
|
|
options: {
|
|
strictMath: true,
|
|
noIeCompat: true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
//字体加载 blueprint
|
|
{
|
|
test: /\.(ttf|eot|svg)$/,
|
|
use: {
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: 'fonts/[hash].[ext]'
|
|
}
|
|
}
|
|
},
|
|
//字体加载 blueprint
|
|
{
|
|
test: /\.(woff|woff2|jpg|png)$/,
|
|
use: {
|
|
loader: 'url-loader',
|
|
options: {
|
|
name: 'fonts/[hash].[ext]',
|
|
limit: 5000,
|
|
mimetype: 'application/font-woff'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /\.(glsl|vs|fs)$/,
|
|
loader: 'shader-loader'
|
|
}
|
|
]
|
|
},
|
|
externals: {
|
|
"golden-layout": "GoldenLayout",
|
|
"three": "THREE"
|
|
},
|
|
plugins: [
|
|
new HtmlWebPackPlugin({
|
|
title: "webCAD",
|
|
template: getpath('../src/index.html')
|
|
}),
|
|
new webpack.DllReferencePlugin({
|
|
context: __dirname,
|
|
manifest: require(`${outputDir}/manifest.json`)
|
|
}),
|
|
new AddAssetHtmlPlugin(
|
|
[
|
|
{
|
|
filepath: "./node_modules/normalize.css/normalize.css",
|
|
typeOfAsset: "css",
|
|
includeSourcemap: false
|
|
},
|
|
{
|
|
filepath: "./node_modules/@blueprintjs/core/lib/css/blueprint.css",
|
|
typeOfAsset: "css",
|
|
includeSourcemap: false
|
|
},
|
|
{
|
|
filepath: getpath(`${outputDir}/dll.js`),
|
|
includeSourcemap: false
|
|
},
|
|
{
|
|
filepath: "./node_modules/three/build/three.min.js",
|
|
includeSourcemap: false
|
|
},
|
|
{
|
|
filepath: "./node_modules//three/examples/js/libs/inflate.min.js",
|
|
includeSourcemap: false
|
|
},
|
|
]
|
|
),
|
|
new webpack.ProvidePlugin({
|
|
ReactDOM: 'react-dom',
|
|
React: 'react',
|
|
THREE: "three"
|
|
}),
|
|
new HardSourceWebpackPlugin(),
|
|
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
|
|
],
|
|
node: false
|
|
};
|
|
|
|
export default config;
|