|
@@ -0,0 +1,106 @@
|
|
|
+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://36.134.91.96:10001/api'
|
|
|
+
|
|
|
+module.exports = {
|
|
|
+ devServer: {
|
|
|
+ port: "8081",
|
|
|
+ open: false,
|
|
|
+ headers: {
|
|
|
+ 'Access-Control-Allow-Origin': '*',
|
|
|
+ },
|
|
|
+ proxy: {
|
|
|
+ '/api': {
|
|
|
+
|
|
|
+ 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`
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|