123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- 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
|