const webpack = require('webpack')
module.exports = {
entry: __dirname + '/index.js',
output: {
path: __dirname + '/dist',
filename: 'out.js',
libraryTarget: 'umd',
},
externals: {
three: 'three',
},
mode: 'development',
watch: true,
watchOptions: {
poll: 100,
aggregateTimeout: 500,
ignored: /node_modules/,
},
devtool: 'source-map',
module: {
rules: [
{
test: /.js$/,
exclude: /(node_modules|bower_components)/ /**加速打包 */,
use: {
loader: 'babel-loader', //https://www.jianshu.com/p/e8cd05e63d97 博客
// options: {
// presets: ['@babel/preset-env'] // //@babel/preset-env 就是用来将ES6语法转换成浏览器能运行的ES5语法的
// }
},
}, //test 用于标识出应该被对应的 loader 进行转换的某个或某些文件,use 是用到的loader,改行意思为遇到js文件用babel-loader加载转换
{
test: /\.worker\.js$/, //以.worker.js结尾的文件将被worker-loader加载
use: { loader: 'worker-loader', options: { inline: 'fallback' } }, //将worker文件打包进来
},
],
},
resolve: {
extensions: ['.js'], //后缀名补全
},
plugins: [],
}