123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- const HtmlWebPackPlugin = require("html-webpack-plugin");
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
- const {CleanWebpackPlugin} = require('clean-webpack-plugin');
- const CopyWebpackPlugin = require('copy-webpack-plugin');
- const WebpackSftpClient = require('webpack-sftp-client');
- const path = require("path");
- module.exports = (env, options) => {
- let outPath = "dist",
- plugins = [
- new CleanWebpackPlugin(),
- new CopyWebpackPlugin([
- {
- from: 'src/assets',
- to: 'assets'
- }
- ]),
- new MiniCssExtractPlugin({filename: "[name][hash].css", chunkFilename: "[id][hash].css"}),
- new HtmlWebPackPlugin({template: './src/index.html', title: '竹香米业数字农业精准管理图', chunksSortMode: "none", inject: true})
- ];
- if (options.mode === 'development') {
- outPath = 'dev'
- } else {
-
- }
- return {
- entry: {
- index: "./src/index.js"
- },
- output: {
- filename: `js/[hash]${parseInt(Math.random()*10000)}.js`,
- path: path.resolve(__dirname, outPath),
- publicPath: ''
- },
- plugins,
- module: {
- rules: [
- {
- test: /\.(js|jsx)$/,
- exclude: /node_modules/,
- include: path.resolve(__dirname, "src"),
- use: [
- {
- loader: "babel-loader"
- }
- ]
- }, {
- test: /\.(sa|sc|)ss$/,
- use: [
- {
- loader: MiniCssExtractPlugin.loader,
- options: {
- hmr: options.mode === 'development'
- }
- }, {
- loader: "css-loader",
- options: {
- modules: false,
- }
- },
- 'sass-loader'
- ]
- }, {
- test: /\.css$/,
- use: [
- {
- loader: MiniCssExtractPlugin.loader,
- options: {
- hmr: options.mode === 'development'
- }
- }, {
- loader: "css-loader",
- options: {
- modules: true,
- }
- }
- ]
- }, {
- test: /\.(jpe?g|png|gif|webp)$/,
- use: [
- {
- loader: "url-loader",
- options: {
-
- limit: 10 * 1024
- }
- }
- ]
- }, {
- test: /\.(wsv|ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
- use: [
- {
- loader: "file-loader",
- options: {
- name: "build/[name].[ext]"
- }
- }
- ]
- }
- ]
- },
- externals: [(context, request, callback) => {
- if (/pe-wasm$/.test(request)) {
- return callback(null, "amd " + request);
- }
- callback();
- }
- ],
- resolve: {
- modules: [
- path.resolve(__dirname, "/src"),
- "node_modules/"
- ],
- extensions: [".js", ".scss"]
- },
- node: {
- process: false,
- global: false,
- fs: "empty"
- },
- devServer: {
- disableHostCheck: true,
- historyApiFallback: true,
- host: '0.0.0.0',
- port: 9008,
- proxy: {
- '/screen':{
- target: 'http://127.0.0.1:9008',
- pathRewrite: {
- '^/screen': ''
- },
- changeOrigin: true
- },
- '/htdata': {
-
- target: 'http://lyfbht.hw.hongweisoft.com',
-
-
-
- changeOrigin: true
- },
- '/product': {
- target: 'http://ghost.nat300.top',
- pathRewrite: {
- '^/product': ''
- },
- changeOrigin: true
- },
- '/forest-admin':{
- target: 'http://129.28.174.150:7050',
- changeOrigin: true
- }
- }
- }
- }
- }
|