diff --git a/nezha-fronted/build/script/buildEnd.sh b/nezha-fronted/build/script/buildEnd.sh new file mode 100644 index 000000000..5908cbac2 --- /dev/null +++ b/nezha-fronted/build/script/buildEnd.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +BUILD_MODE=$1 + +CUR_PATH=`pwd` +echo 'cur path is '${CUR_PATH} +DIST_PATH=$CUR_PATH/dist + +echo 'dist dir path is '${DIST_PATH} + +cd $DIST_PATH + +if [[ 'all' == "${BUILD_MODE}" ]];then + echo 'build all to zip file ,now moving map picture to static dir...' + \cp -rf ../static/Tiles/ $DIST_PATH/static/ +fi +echo 'start create zip...' +find ./ * -exec touch -t $(date +%Y%m%d0000.00) {} \; +zip -rX nz-gui.zip ./* >/dev/null + +MD5=$(md5sum nz-gui.zip |awk '{print $1}'|cut -c 1-8) +mv nz-gui.zip nz-gui-${MD5}.zip + +echo 'package zip file is complate ,please check in '${DIST_PATH} diff --git a/nezha-fronted/build/script/buildStart.sh b/nezha-fronted/build/script/buildStart.sh new file mode 100644 index 000000000..c4e93025f --- /dev/null +++ b/nezha-fronted/build/script/buildStart.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo 'clean dist dir ...' +rm -rf dist diff --git a/nezha-fronted/build/webpack.prod.conf.js b/nezha-fronted/build/webpack.prod.conf.js index 3b10ea9ea..889bbd490 100644 --- a/nezha-fronted/build/webpack.prod.conf.js +++ b/nezha-fronted/build/webpack.prod.conf.js @@ -14,6 +14,7 @@ const fileManagerPlugin = require('filemanager-webpack-plugin') const WebpackZipPlugin = require('webpack-zip-plugin') const GitRevisionPlugin = require('git-revision-webpack-plugin') const GenerateAssetPlugin = require('generate-asset-webpack-plugin'); +const WebpackShellPlugin = require('webpack-shell-plugin'); const serverConfig = require('../static/config.json')//引入根目录下的配置文件 @@ -41,7 +42,7 @@ const webpackConfig = merge(baseWebpackConfig, { output: { path: config.build.assetsRoot, filename: utils.assetsPath('js/[name].[chunkhash].js'), - chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') + chunkFilename: utils.assetsPath('js[chunkhash].js') }, plugins: [ /*new GenerateAssetPlugin({ @@ -86,6 +87,7 @@ const webpackConfig = merge(baseWebpackConfig, { new HtmlWebpackPlugin({ filename: config.build.index, template: 'index.html', + hash:false, inject: true, minify: { removeComments: true, @@ -185,11 +187,15 @@ if(process.env.NODE_ENV == 'development'){ ) }else{ webpackConfig.plugins.push( - new WebpackZipPlugin({ - initialFile: './dist', - endPath: './dist', - zipName: 'nz-gui.zip', - behindShell: 'cd '+path.join(__dirname,'../dist/')+";md5=`md5sum nz-gui.zip |awk '{print $1}'|cut -c 1-8`;mv nz-gui.zip nz-gui-${md5}.zip;"+(process.env.BUILD_MODE=='all'?'mkdir -p ./dist/static;echo "start add map picture to zip file,it will take a few moment,please wait...";cp -r ../static/Tiles dist/static/;zip -gr nz-gui-${md5}.zip dist/static/Tiles>/dev/null;rm -rf dist;':'') + // new WebpackZipPlugin({ + // initialFile: './dist', + // endPath: './dist', + // zipName: 'nz-gui.zip', + // behindShell: 'cd '+path.join(__dirname,'../dist/')+";md5=`md5sum nz-gui.zip |awk '{print $1}'|cut -c 1-8`;mv nz-gui.zip nz-gui-${md5}.zip;"+(process.env.BUILD_MODE=='all'?'mkdir -p ./dist/static;echo "start add map picture to zip file,it will take a few moment,please wait...";cp -r ../static/Tiles dist/static/;zip -gr nz-gui-${md5}.zip dist/static/Tiles>/dev/null;rm -rf dist;':'') + // }), + new WebpackShellPlugin({ + onBuildStart: ['/bin/bash '+path.join(__dirname,'script')+'/buildStart.sh'], + onBuildEnd: ['/bin/bash '+path.join(__dirname,'script')+'/buildEnd.sh '+process.env.BUILD_MODE] }), new fileManagerPlugin({ onStart:[ diff --git a/nezha-fronted/config/index.js b/nezha-fronted/config/index.js index c54e7c6a5..3cf6aeb49 100644 --- a/nezha-fronted/config/index.js +++ b/nezha-fronted/config/index.js @@ -55,7 +55,7 @@ module.exports = { * Source Maps */ - productionSourceMap: true, + productionSourceMap: false, // https://webpack.js.org/configuration/devtool/#production devtool: '#source-map', diff --git a/nezha-fronted/package.json b/nezha-fronted/package.json index 72628e518..32caa6ba6 100644 --- a/nezha-fronted/package.json +++ b/nezha-fronted/package.json @@ -95,6 +95,7 @@ "webpack-bundle-analyzer": "^2.9.0", "webpack-dev-server": "^2.9.1", "webpack-merge": "^4.1.0", + "webpack-shell-plugin": "^0.5.0", "webpack-zip-plugin": "^0.1.6" }, "engines": {