feat:修改原有打包方式
This commit is contained in:
24
nezha-fronted/build/script/buildEnd.sh
Normal file
24
nezha-fronted/build/script/buildEnd.sh
Normal file
@@ -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}
|
||||
3
nezha-fronted/build/script/buildStart.sh
Normal file
3
nezha-fronted/build/script/buildStart.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo 'clean dist dir ...'
|
||||
rm -rf dist
|
||||
@@ -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:[
|
||||
|
||||
@@ -55,7 +55,7 @@ module.exports = {
|
||||
* Source Maps
|
||||
*/
|
||||
|
||||
productionSourceMap: true,
|
||||
productionSourceMap: false,
|
||||
// https://webpack.js.org/configuration/devtool/#production
|
||||
devtool: '#source-map',
|
||||
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user