123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- const path = require('path')
- const webpack = require('webpack')
- const CompressionWebpackPlugin = require('compression-webpack-plugin')
- const GenerateAssetPlugin = require('generate-asset-webpack-plugin')
- const Timestamp = new Date().getTime()
- const createServerConfig = function (compilation) {
- let config = { version: new Date().getTime() }
- return JSON.stringify(config)
- }
- const resolve = dir => {
- return path.join(__dirname, dir)
- }
- const BASE_URL = process.env.NODE_ENV === 'production'
- ? '/'
- : '/';
- const ip = 'http://120.79.80.64:8050'
- module.exports = {
- devServer: {
- port: "8080",
- open: false,
- headers: {
- 'Access-Control-Allow-Origin': '*',
- },
- proxy: {
- '/cloudApi': {
- target: ip,
- ws: true,
- pathRewrite: {
- '^/api': '/'
- }
- },
- '/purchaseContract': {
- target: ip,
- ws: true,
- pathRewrite: {
- '^/api': '/'
- }
- },
- '/supplier': {
- target: ip,
- ws: true,
- pathRewrite: {
- '^/api': '/'
- }
- },
- '/javaApi': {
- target: ip,
- ws: true,
- pathRewrite: {
- '^/api': '/'
- }
- },
-
- }
- },
-
-
-
-
-
-
-
- publicPath: BASE_URL,
-
-
-
- lintOnSave: true,
- chainWebpack: config => {
- config.resolve.alias
- .set('@', resolve('src'))
- .set('_c', resolve('src/components'))
- },
-
- productionSourceMap: false,
- configureWebpack: config => {
-
- if (process.env.NODE_ENV !== 'production') return
- else config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
- config.plugins.push(
- new CompressionWebpackPlugin({
-
- test: /\.(js|css|svg|woff|ttf|json|html)$/,
-
- threshold: 10240
-
- })
- )
- config.plugins.push(
- new GenerateAssetPlugin({
- filename: 'version.json',
- fn: (compilation, cb) => {
- cb(null, createServerConfig(compilation))
- },
- extraFiles: []
- })
- )
- config.plugins.push(
- new webpack.ProvidePlugin({
- $: 'jquery',
- jQuery: 'jquery',
- 'window.jQuery': 'jquery'
- })
- )
- config.output.filename = `js/[name].${Timestamp}.js`
- config.output.chunkFilename = `js/[name].${Timestamp}.js`
- }
-
-
-
-
- }
|