const webpack = require('webpack') const path = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin'); const config = { entry: path.join(__dirname, 'src/CAD/index.ts'), output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', globalObject: 'this' }, module: { rules: [ { test: /\.worker\.js$/, //以.worker.js结尾的文件将被worker-loader加载 use: { loader: 'worker-loader' } }, // { // test: /\.js$/, // exclude: /node_modules/, // use: { // loader: 'babel-loader' // } // }, { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ }, { test: /\.css$/, use: [ {loader: 'style-loader'}, {loader: 'css-loader'}, { loader: 'postcss-loader', options: { plugins: [require('autoprefixer')] } } ] }, { test: /\.(png|jpg|gif|woff|eot|ttf|svg)$/, use: { loader: 'url-loader', options: { limit: 8192, name: "assets/[name].[ext]" } } } ] }, resolve: { extensions: ['.tsx', '.ts', '.js'] }, plugins: [ new webpack.HotModuleReplacementPlugin(), new CopyWebpackPlugin([{ from: path.resolve(__dirname, 'static'), to: path.resolve(__dirname, 'dist', 'static'), ignore: ['.*'] }]), new HtmlWebpackPlugin({ template: path.join(__dirname, 'static/index.html'), minify: { removeComments: false, collapseWhitespace: false } }) ] , devServer: { contentBase: path.join(__dirname, "dist"), port: 8001, hot: true, host: '0.0.0.0' } } module.exports = config