From 8a42987cbc94722ab24f805925b5922a1af4b217 Mon Sep 17 00:00:00 2001 From: LAPTOP-RI7D261L\Mr Ke <545800322@qq.com> Date: Tue, 04 Feb 2020 12:34:19 +0800 Subject: [PATCH] 修改 --- .command/.conf/webpack.test.js | 91 +++++++++++++++++++++++---------------------- 1 files changed, 47 insertions(+), 44 deletions(-) diff --git a/.command/.conf/webpack.test.js b/.command/.conf/webpack.test.js index 556a463..9dc2be5 100644 --- a/.command/.conf/webpack.test.js +++ b/.command/.conf/webpack.test.js @@ -1,37 +1,41 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin"); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const webpack = require('webpack'); -const path = require('path'); -const fs = require('fs'); +const HtmlWebpackPlugin = require("html-webpack-plugin"); +const CopyWebpackPlugin = require("copy-webpack-plugin"); +const webpack = require("webpack"); +const path = require("path"); +const fs = require("fs"); -const rules = [{ - test: /\.(js|jsx)$/i, - loader: 'babel-loader' -}, { - test: /\.css$/i, - use: [MiniCssExtractPlugin.loader, 'css-loader'] -}, { - test: /\.s[ac]ss$/i, - use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'] -}, { - test: /\.less$/i, - use: [MiniCssExtractPlugin.loader, 'css-loader', 'less-loader'] -}, { - test: /\.(svg|png|jpg|gif)$/i, - loader: 'file-loader', - options: { - name: '[name].[ext]?[hash]', - outputPath: 'static/' +const rules = [ + { + test: /\.(js|jsx)$/i, + loader: "babel-loader" + }, + { + test: /\.css$/i, + use: [MiniCssExtractPlugin.loader, "css-loader"] + }, + { + test: /\.s[ac]ss$/i, + use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"] + }, + { + test: /\.less$/i, + use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"] + }, + { + test: /\.(svg|png|jpg|gif|ttf)$/i, + loader: "file-loader", + options: { + name: "[name].[ext]?[hash]", + outputPath: "static/" + } } -}]; - - +]; const plugins = [ new webpack.HotModuleReplacementPlugin(), new HtmlWebpackPlugin({ - template: './src/conf/index.html', + template: "./src/conf/index.html", minify: true }), new MiniCssExtractPlugin({ @@ -39,24 +43,23 @@ }) ]; -if (fs.existsSync(path.resolve(__dirname, './src/copy'))) { - plugins.push(new CopyWebpackPlugin([{ - to: path.resolve(__dirname, './dist-debug'), - from: './src/copy', - toType: 'dir' - }])); +if (fs.existsSync(path.resolve(__dirname, "./src/copy"))) { + plugins.push( + new CopyWebpackPlugin([ + { + to: path.resolve(__dirname, "./dist-debug"), + from: "./src/copy", + toType: "dir" + } + ]) + ); } - module.exports = { - entry: [ - './src/conf/reset.scss', - './src/index.jsx', - './src/conf/cover.scss' - ], + entry: ["./src/conf/reset.scss", "./src/index.jsx", "./src/conf/cover.scss"], output: { - path: path.resolve(__dirname, './dist-debug'), - filename: 'index.js?[hash]' + path: path.resolve(__dirname, "./dist-debug"), + filename: "index.js?[hash]" }, resolve: { extensions: [".js", ".jsx", ".ts", ".tsx"] @@ -65,10 +68,10 @@ rules }, devServer: { - contentBase: './dist-debug', + contentBase: "./dist-debug", hot: true }, - mode: 'development', - devtool: 'inline-source-map', + mode: "development", + devtool: "inline-source-map", plugins }; -- Gitblit v1.8.0