UNPKG

custom-app

Version:

ITIMS��Ʒ�鿪��ר��React���,�Dz��ý��ּ�dhcc-app���������

58 lines (56 loc) 1.63 kB
let path = require("path"); let webpack = require("webpack"); //自动生成html的插件 let HtmlWebpackPlugin = require("html-webpack-plugin"); //打包前清理输出目录 let CleanWebpackPlugin = require("clean-webpack-plugin"); let projectName = 'react' + path.basename(path.resolve(__dirname, '..')) let deployPath = path.join(__dirname, projectName, 'src'); let outputPath = path.join(__dirname, projectName, 'build'); console.log(deployPath + "----------") console.log(outputPath + "----------") module.exports = { mode: 'production', devtool: "eval-source-map", entry: path.join(deployPath, 'index.js'), output: { filename: "index.js", path: outputPath }, plugins: [ //new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: [outputPath] }), new HtmlWebpackPlugin({ minify: { removeAttributeQuotes: true }, template: path.join(deployPath, 'index.html'), filename: 'index.html' }) ], module: { rules: [ { test: /\.css$/, use: ['style-loader', 'css-loader']//从右往左写,webpack特性 }, {//解析字体文件、图片、svg等 test: /.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader' }, {//转义es6/es7/jsx test: /\.js$/, exclude: /node_modules/, // include: reactAppPath, use: { loader: 'babel-loader', options: { presets: [ "@babel/preset-env", "@babel/preset-react" ] } } } ] } }