这是我第一次使用Webpack。我只想使用Webpack将THREE.js绑定到我的应用程序中。
package.json
{
"name": "my-display",
"version": "1.0.0",
"description": "",
"main": "./index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --mode production",
"watch": "webpack --mode development --watch"
},
"author": "",
"license": "ISC",
"dependencies": {
"three": "^0.99.0"
},
"devDependencies": {
"webpack": "^4.28.0",
"webpack-cli": "^3.1.2"
}
}
webpack.config.js
const path = require('path');
module.exports = {
entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
watchOptions: {
ignored: /node_modules/
}
};
index.html
import { Scene } from 'three';
const scene = new Scene();
console.log("hello world");
运行npm run build
WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
bundle.js (529 KiB)
WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
main (529 KiB)
bundle.js
WARNING in webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/
但是当我运行开发环境中的npm run watch
时,我没有得到这样的警告。
这是预期的行为吗? THREE.js这么大吗?