速度有点慢, 有什么办法优化编译速度吗?
当前配置:
webpack.config.js
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
const smp = new SpeedMeasurePlugin();
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = smp.wrap({
'entry': ['./src/index.ts'],
'output': {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
},
'mode': 'development',
'devtool': 'eval-source-map',
'devServer': {
port: '8000',
host: '0.0.0.0',
public: 'localhost:8000',
open: false,
quiet: true,
},
'plugins': [
new ForkTsCheckerWebpackPlugin(),
new webpack.ProgressPlugin(),
new HtmlWebpackPlugin({
template: './src/index.html',
inject: true,
open: false,
}),
],
'module': {
rules: [
{
test: /\.(js|jsx|tsx|ts)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ['file-loader'],
},
],
},
'resolve': {
extensions: ['.tsx', '.ts', '.js'],
},
});
.babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-TypeScript"
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
]
}
tsconfig.json
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/",
"target": "ES2020",
"moduleResolution": "node", // threejs need
"module": "CommonJS",
"esModuleInterop": true,
"noImplicitAny": true,
"sourceMap": true,
"isolatedModules": true,
"strictBindCallApply": true,
},
"exclude": [
"node_modules"
],
"include": [
"src/**/*.ts",
"types/**/*.d.ts"
]
}
``
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.