From 48f7d7188903bda6354f87c0d553cd8d15808210 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 5 May 2022 10:36:00 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=9A=82=E5=AD=98=E5=A4=9A?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/build/webpack.base.conf.js | 2 +- nezha-fronted/build/webpack.dev.conf.js | 8 +- .../build/webpack.dev.only-html.conf.js | 6 +- nezha-fronted/build/webpack.prod-html.conf.js | 281 +++++++++++++ nezha-fronted/build/webpack.prod.conf.js | 389 ++++++------------ nezha-fronted/src/{ => app}/App.vue | 0 nezha-fronted/{ => src/app}/index.html | 0 nezha-fronted/src/{ => app}/main.js | 26 +- .../src/components/common/js/validate.js | 2 +- .../common/rightBox/editEndpointBoxNew.vue | 2 +- .../common/rightBox/ipDetailsBox.vue | 2 +- .../components/common/rightBox/ipamBox.vue | 2 +- .../src/components/page/config/licenseGen.vue | 2 +- .../page/dashboard/overview/chartConfig.vue | 2 +- .../{ => src/entrance}/entrance.html | 0 nezha-fronted/src/entrance/entrance.main.js | 2 +- nezha-fronted/src/permission.js | 324 ++++++++------- 17 files changed, 600 insertions(+), 450 deletions(-) create mode 100644 nezha-fronted/build/webpack.prod-html.conf.js rename nezha-fronted/src/{ => app}/App.vue (100%) rename nezha-fronted/{ => src/app}/index.html (100%) rename nezha-fronted/src/{ => app}/main.js (86%) rename nezha-fronted/{ => src/entrance}/entrance.html (100%) diff --git a/nezha-fronted/build/webpack.base.conf.js b/nezha-fronted/build/webpack.base.conf.js index 80675a423..e9eb43ff9 100644 --- a/nezha-fronted/build/webpack.base.conf.js +++ b/nezha-fronted/build/webpack.base.conf.js @@ -34,7 +34,7 @@ const onlyHtml = { module.exports = { context: path.resolve(__dirname, '../'), entry: { - app: './src/main.js', + app: './src/app/main.js', entrance: './src/entrance/entrance.main.js' }, output: { diff --git a/nezha-fronted/build/webpack.dev.conf.js b/nezha-fronted/build/webpack.dev.conf.js index 1d6c16bab..50aed5303 100644 --- a/nezha-fronted/build/webpack.dev.conf.js +++ b/nezha-fronted/build/webpack.dev.conf.js @@ -25,11 +25,11 @@ const devWebpackConfig = merge(baseWebpackConfig, { clientLogLevel: 'warning', historyApiFallback: { rewrites: [ - { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') } + { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'src/app/index.html') } ] }, hot: true, - inline:true, + inline: true, contentBase: false, // since we use CopyWebpackPlugin. compress: true, host: HOST || config.dev.host, @@ -57,9 +57,9 @@ const devWebpackConfig = merge(baseWebpackConfig, { new HtmlWebpackPlugin({ favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'), filename: 'index.html', - template: 'index.html', + template: 'src/app/index.html', inject: true, - chunks: ['entrance'] + chunks: ['app'] }), // copy custom static assets new CopyWebpackPlugin([ diff --git a/nezha-fronted/build/webpack.dev.only-html.conf.js b/nezha-fronted/build/webpack.dev.only-html.conf.js index 1c9a25713..1b8cb0f13 100644 --- a/nezha-fronted/build/webpack.dev.only-html.conf.js +++ b/nezha-fronted/build/webpack.dev.only-html.conf.js @@ -26,7 +26,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { clientLogLevel: 'warning', historyApiFallback: { rewrites: [ - { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') } + { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'src/entrance/entrance.html') } ] }, hot: true, @@ -58,9 +58,9 @@ const devWebpackConfig = merge(baseWebpackConfig, { new HtmlWebpackPlugin({ favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'), filename: 'entrance.html', - template: 'entrance.html', + template: 'src/entrance/entrance.html', inject: true, - chunks: ['app'] + chunks: ['entrance'] }), // copy custom static assets new CopyWebpackPlugin([ diff --git a/nezha-fronted/build/webpack.prod-html.conf.js b/nezha-fronted/build/webpack.prod-html.conf.js new file mode 100644 index 000000000..ed089f615 --- /dev/null +++ b/nezha-fronted/build/webpack.prod-html.conf.js @@ -0,0 +1,281 @@ +'use strict' +const path = require('path') + +const utils = require('./utils') +const webpack = require('webpack') +const config = require('../config') +const merge = require('webpack-merge') +const baseWebpackConfig = require('./webpack.base.conf') +console.log(process.env.ONLY_HTML,baseWebpackConfig) +const CopyWebpackPlugin = require('copy-webpack-plugin') +const HtmlWebpackPlugin = require('html-webpack-plugin') +const ExtractTextPlugin = require('extract-text-webpack-plugin') +const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') +const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin') +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')// 引入根目录下的配置文件 +const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin') + +// const gitRevisionPlugin = new GitRevisionPlugin(); +const createJson = function () { + // serverConfig.version=config.build.version +"-"+gitRevisionPlugin.commithash(); + serverConfig.version = config.build.version + return JSON.stringify(serverConfig) +} + +const env = require('../config/prod.env') +/* const GenerateAssetPlugin = require('generate-asset-webpack-plugin'); +const createConfig = function(compilation){ + let cfgJson={baseUrl:"http://192.168.40.247:8080/nz-admin"}; + return JSON.stringify(cfgJson); +} */ +let webpackConfig = {} +webpackConfig = merge(baseWebpackConfig, { + module: { + rules: utils.styleLoaders({ + sourceMap: config.build.productionSourceMap, + extract: true, + usePostCSS: true + }) + }, + devtool: config.build.productionSourceMap ? config.build.devtool : false, + output: { + path: config.build.assetsRoot, + filename: utils.assetsPath('js/[name].[chunkhash].js'), + chunkFilename: utils.assetsPath('js/[name].[chunkhash].js') + }, + plugins: [ + /* new GenerateAssetPlugin({ + filename: 'config.json', + fn: (compilation, cb) => { + cb(null, createConfig(compilation)); + }, + extraFiles: [] + }), */ + // http://vuejs.github.io/vue-loader/en/workflow/production.html + new webpack.DefinePlugin({ + 'process.env': env + }), + new ParallelUglifyPlugin({ + cacheDir: '.cache/', + uglifyJS: { + output: { + comments: false + }, + warnings: false, + compress: { + drop_debugger: true, + drop_console: true + } + } + }), + // extract css into its own file + new ExtractTextPlugin({ + filename: utils.assetsPath('css/[name].[contenthash].css'), + // Setting the following option to `false` will not extract CSS from codesplit chunks. + // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. + // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, + // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 + allChunks: true + }), + // Compress extracted CSS. We are using this plugin so that possible + // duplicated CSS from different components can be deduped. + new OptimizeCSSPlugin({ + cssProcessorOptions: config.build.productionSourceMap + ? { safe: true, map: { inline: false } } + : { safe: true } + }), + // generate dist index.html with correct asset hash for caching. + // you can customize output by editing /index.html + // see https://github.com/ampedandwired/html-webpack-plugin + new HtmlWebpackPlugin({ + favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'), + filename: config.build.index, + template: 'src/entrance/entrance.html', + inlineSource: '.(js|css)$', // embed all javascript and css inline + hash: false, + inject: true, + minify: { + removeComments: true, + collapseWhitespace: true, + removeAttributeQuotes: true + // more options: + // https://github.com/kangax/html-minifier#options-quick-reference + }, + // necessary to consistently work with multiple chunks via CommonsChunkPlugin + chunksSortMode: 'dependency', + chunks: ['entrance'] + }), + new HtmlWebpackInlineSourcePlugin(), + new GenerateAssetPlugin({ + filename: 'static/config.json', + fn: (compilation, cb) => { + cb(null, createJson()) + } + }), + // keep module.id stable when vendor modules does not change + new webpack.HashedModuleIdsPlugin(), + // enable scope hoisting + new webpack.optimize.ModuleConcatenationPlugin(), + // split vendor js into its own file + new webpack.optimize.CommonsChunkPlugin({ + name: 'vendor', + minChunks (module) { + // any required modules inside node_modules are extracted to vendor + return ( + module.resource && + /\.js$/.test(module.resource) && + module.resource.indexOf( + path.join(__dirname, '../node_modules') + ) === 0 + ) + } + }), + // extract webpack runtime and module manifest to its own file in order to + // prevent vendor hash from being updated whenever app bundle is updated + new webpack.optimize.CommonsChunkPlugin({ + name: 'manifest', + minChunks: Infinity + }), + // This instance extracts shared chunks from code splitted chunks and bundles them + // in a separate chunk, similar to the vendor chunk + // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk + new webpack.optimize.CommonsChunkPlugin({ + name: 'entrance', + async: 'vendor-async', + children: true, + minChunks: 3 + }), + + // copy custom static assets + new CopyWebpackPlugin([ + { + from: path.resolve(__dirname, '../static'), + to: config.build.assetsSubDirectory, + ignore: ['*'] + }, + { + from: path.resolve(__dirname, '../src/components/chart'), + to: 'components', + ignore: ['.*'] + } + ]) + ] +}) + +if (process.env.NODE_ENV == 'development') { + webpackConfig.plugins.push( + new fileManagerPlugin({ + onStart: [ + { + delete: [path.join(__dirname, '../dist/')] + } + ], + onEnd: [ + { + move: [ + { source: path.join(__dirname, '../dist', '/static/config.json'), destination: path.join(__dirname, '../dist/config.json') } + + ], + mkdir: [ + path.join(__dirname, '../dist', '/static') + ], + copy: [ + { source: path.join(__dirname, '../dist', '/config.json'), destination: path.join(__dirname, '../dist', '/static/config.json') } + ] + }, + { + delete: [ + path.join(__dirname, '../dist', '/config.json') + ] + }, + { + archive: [ + { source: path.join(__dirname, '../dist'), destination: path.join(__dirname, '../dist', '/nz-gui.zip') } + ] + } + ] + }) + ) +} else { + webpackConfig.plugins.push( + new fileManagerPlugin({ + onStart: [ + { + delete: [path.join(__dirname, '../dist/')] + } + ], + onEnd: [ + { + move: [ + { source: path.join(__dirname, '../dist', '/static/config.json'), destination: path.join(__dirname, '../dist/config.json') } + + ], + mkdir: [ + path.join(__dirname, '../dist', '/static') + ], + copy: [ + { source: path.join(__dirname, '../dist', '/config.json'), destination: path.join(__dirname, '../dist', '/static/config.json') } + ] + }, + { + delete: [ + path.join(__dirname, '../dist', '/config.json'), + path.join(__dirname, '../.cache/') + ] + }, + { + archive: [ + { source: path.join(__dirname, '../dist'), destination: path.join(__dirname, '../dist', '/nz-gui.zip') } + ] + } + ] + }) + // 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: [ + // { + // delete: [path.join(__dirname, '../dist/')] + // } + // ] + // }) + ) +} + +if (config.build.productionGzip) { + const CompressionWebpackPlugin = require('compression-webpack-plugin') + + webpackConfig.plugins.push( + new CompressionWebpackPlugin({ + asset: '[path].gz[query]', + algorithm: 'gzip', + test: new RegExp( + '\\.(' + + config.build.productionGzipExtensions.join('|') + + ')$' + ), + threshold: 10240, + minRatio: 0.8 + }) + ) +} + +if (config.build.bundleAnalyzerReport) { + const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin + webpackConfig.plugins.push(new BundleAnalyzerPlugin()) +} + +module.exports = webpackConfig diff --git a/nezha-fronted/build/webpack.prod.conf.js b/nezha-fronted/build/webpack.prod.conf.js index 96f1b0dfc..dbeae7d18 100644 --- a/nezha-fronted/build/webpack.prod.conf.js +++ b/nezha-fronted/build/webpack.prod.conf.js @@ -34,271 +34,136 @@ const createConfig = function(compilation){ return JSON.stringify(cfgJson); } */ let webpackConfig = {} -if (!process.env.ONLY_HTML) { - webpackConfig = merge(baseWebpackConfig, { - module: { - rules: utils.styleLoaders({ - sourceMap: config.build.productionSourceMap, - extract: true, - usePostCSS: true - }) - }, - devtool: config.build.productionSourceMap ? config.build.devtool : false, - output: { - path: config.build.assetsRoot, - filename: utils.assetsPath('js/[name].[chunkhash].js'), - chunkFilename: utils.assetsPath('js/[name].[chunkhash].js') - }, - plugins: [ - /* new GenerateAssetPlugin({ - filename: 'config.json', - fn: (compilation, cb) => { - cb(null, createConfig(compilation)); +webpackConfig = merge(baseWebpackConfig, { + module: { + rules: utils.styleLoaders({ + sourceMap: config.build.productionSourceMap, + extract: true, + usePostCSS: true + }) + }, + devtool: config.build.productionSourceMap ? config.build.devtool : false, + output: { + path: config.build.assetsRoot, + filename: utils.assetsPath('js/[name].[chunkhash].js'), + chunkFilename: utils.assetsPath('js/[name].[chunkhash].js') + }, + plugins: [ + /* new GenerateAssetPlugin({ + filename: 'config.json', + fn: (compilation, cb) => { + cb(null, createConfig(compilation)); + }, + extraFiles: [] + }), */ + // http://vuejs.github.io/vue-loader/en/workflow/production.html + new webpack.DefinePlugin({ + 'process.env': env + }), + new ParallelUglifyPlugin({ + cacheDir: '.cache/', + uglifyJS: { + output: { + comments: false }, - extraFiles: [] - }), */ - // http://vuejs.github.io/vue-loader/en/workflow/production.html - new webpack.DefinePlugin({ - 'process.env': env - }), - new ParallelUglifyPlugin({ - cacheDir: '.cache/', - uglifyJS: { - output: { - comments: false - }, - warnings: false, - compress: { - drop_debugger: true, - drop_console: true - } + warnings: false, + compress: { + drop_debugger: true, + drop_console: true } - }), - // extract css into its own file - new ExtractTextPlugin({ - filename: utils.assetsPath('css/[name].[contenthash].css'), - // Setting the following option to `false` will not extract CSS from codesplit chunks. - // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. - // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, - // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 - allChunks: true - }), - // Compress extracted CSS. We are using this plugin so that possible - // duplicated CSS from different components can be deduped. - new OptimizeCSSPlugin({ - cssProcessorOptions: config.build.productionSourceMap - ? { safe: true, map: { inline: false } } - : { safe: true } - }), - // generate dist index.html with correct asset hash for caching. - // you can customize output by editing /index.html - // see https://github.com/ampedandwired/html-webpack-plugin - new HtmlWebpackPlugin({ - favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'), - filename: config.build.index, - template: 'index.html', - hash: false, - inject: true, - minify: { - removeComments: true, - collapseWhitespace: true, - removeAttributeQuotes: true - // more options: - // https://github.com/kangax/html-minifier#options-quick-reference - }, - // necessary to consistently work with multiple chunks via CommonsChunkPlugin - chunksSortMode: 'dependency', - chunks: ['entrance'] - }), - new GenerateAssetPlugin({ - filename: 'static/config.json', - fn: (compilation, cb) => { - cb(null, createJson()) - } - }), - // keep module.id stable when vendor modules does not change - new webpack.HashedModuleIdsPlugin(), - // enable scope hoisting - new webpack.optimize.ModuleConcatenationPlugin(), - // split vendor js into its own file - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', - minChunks (module) { - // any required modules inside node_modules are extracted to vendor - return ( - module.resource && - /\.js$/.test(module.resource) && - module.resource.indexOf( - path.join(__dirname, '../node_modules') - ) === 0 - ) - } - }), - // extract webpack runtime and module manifest to its own file in order to - // prevent vendor hash from being updated whenever app bundle is updated - new webpack.optimize.CommonsChunkPlugin({ - name: 'manifest', - minChunks: Infinity - }), - // This instance extracts shared chunks from code splitted chunks and bundles them - // in a separate chunk, similar to the vendor chunk - // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk - new webpack.optimize.CommonsChunkPlugin({ - name: 'app', - async: 'vendor-async', - children: true, - minChunks: 3 - }), + } + }), + // extract css into its own file + new ExtractTextPlugin({ + filename: utils.assetsPath('css/[name].[contenthash].css'), + // Setting the following option to `false` will not extract CSS from codesplit chunks. + // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. + // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, + // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 + allChunks: true + }), + // Compress extracted CSS. We are using this plugin so that possible + // duplicated CSS from different components can be deduped. + new OptimizeCSSPlugin({ + cssProcessorOptions: config.build.productionSourceMap + ? { safe: true, map: { inline: false } } + : { safe: true } + }), + // generate dist index.html with correct asset hash for caching. + // you can customize output by editing /index.html + // see https://github.com/ampedandwired/html-webpack-plugin + new HtmlWebpackPlugin({ + favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'), + filename: config.build.index, + template: 'src/app/index.html', + hash: false, + inject: true, + minify: { + removeComments: true, + collapseWhitespace: true, + removeAttributeQuotes: true + // more options: + // https://github.com/kangax/html-minifier#options-quick-reference + }, + // necessary to consistently work with multiple chunks via CommonsChunkPlugin + chunksSortMode: 'dependency', + chunks: ['app'] + }), + new GenerateAssetPlugin({ + filename: 'static/config.json', + fn: (compilation, cb) => { + cb(null, createJson()) + } + }), + // keep module.id stable when vendor modules does not change + new webpack.HashedModuleIdsPlugin(), + // enable scope hoisting + new webpack.optimize.ModuleConcatenationPlugin(), + // split vendor js into its own file + new webpack.optimize.CommonsChunkPlugin({ + name: 'vendor', + minChunks (module) { + // any required modules inside node_modules are extracted to vendor + return ( + module.resource && + /\.js$/.test(module.resource) && + module.resource.indexOf( + path.join(__dirname, '../node_modules') + ) === 0 + ) + } + }), + // extract webpack runtime and module manifest to its own file in order to + // prevent vendor hash from being updated whenever app bundle is updated + new webpack.optimize.CommonsChunkPlugin({ + name: 'manifest', + minChunks: Infinity + }), + // This instance extracts shared chunks from code splitted chunks and bundles them + // in a separate chunk, similar to the vendor chunk + // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk + new webpack.optimize.CommonsChunkPlugin({ + name: 'app', + async: 'vendor-async', + children: true, + minChunks: 3 + }), - // copy custom static assets - new CopyWebpackPlugin([ - { - from: path.resolve(__dirname, '../static'), - to: config.build.assetsSubDirectory, - ignore: ['*'] - }, - { - from: path.resolve(__dirname, '../src/components/chart'), - to: 'components', - ignore: ['.*'] - } - ]) - ] - }) -} else { - webpackConfig = merge(baseWebpackConfig, { - module: { - rules: utils.styleLoaders({ - sourceMap: config.build.productionSourceMap, - extract: true, - usePostCSS: true - }) - }, - devtool: config.build.productionSourceMap ? config.build.devtool : false, - output: { - path: config.build.assetsRoot, - filename: utils.assetsPath('js/[name].[chunkhash].js'), - chunkFilename: utils.assetsPath('js/[name].[chunkhash].js') - }, - plugins: [ - /* new GenerateAssetPlugin({ - filename: 'config.json', - fn: (compilation, cb) => { - cb(null, createConfig(compilation)); - }, - extraFiles: [] - }), */ - // http://vuejs.github.io/vue-loader/en/workflow/production.html - new webpack.DefinePlugin({ - 'process.env': env - }), - new ParallelUglifyPlugin({ - cacheDir: '.cache/', - uglifyJS: { - output: { - comments: false - }, - warnings: false, - compress: { - drop_debugger: true, - drop_console: true - } - } - }), - // extract css into its own file - new ExtractTextPlugin({ - filename: utils.assetsPath('css/[name].[contenthash].css'), - // Setting the following option to `false` will not extract CSS from codesplit chunks. - // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. - // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, - // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 - allChunks: true - }), - // Compress extracted CSS. We are using this plugin so that possible - // duplicated CSS from different components can be deduped. - new OptimizeCSSPlugin({ - cssProcessorOptions: config.build.productionSourceMap - ? { safe: true, map: { inline: false } } - : { safe: true } - }), - // generate dist index.html with correct asset hash for caching. - // you can customize output by editing /index.html - // see https://github.com/ampedandwired/html-webpack-plugin - new HtmlWebpackPlugin({ - favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'), - filename: config.build.index, - template: 'entrance.html', - inlineSource: '.(js|css)$', // embed all javascript and css inline - hash: false, - inject: true, - minify: { - removeComments: true, - collapseWhitespace: true, - removeAttributeQuotes: true - // more options: - // https://github.com/kangax/html-minifier#options-quick-reference - }, - // necessary to consistently work with multiple chunks via CommonsChunkPlugin - chunksSortMode: 'dependency', - chunks: ['app'] - }), - new HtmlWebpackInlineSourcePlugin(), - new GenerateAssetPlugin({ - filename: 'static/config.json', - fn: (compilation, cb) => { - cb(null, createJson()) - } - }), - // keep module.id stable when vendor modules does not change - new webpack.HashedModuleIdsPlugin(), - // enable scope hoisting - new webpack.optimize.ModuleConcatenationPlugin(), - // split vendor js into its own file - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', - minChunks (module) { - // any required modules inside node_modules are extracted to vendor - return ( - module.resource && - /\.js$/.test(module.resource) && - module.resource.indexOf( - path.join(__dirname, '../node_modules') - ) === 0 - ) - } - }), - // extract webpack runtime and module manifest to its own file in order to - // prevent vendor hash from being updated whenever app bundle is updated - new webpack.optimize.CommonsChunkPlugin({ - name: 'manifest', - minChunks: Infinity - }), - // This instance extracts shared chunks from code splitted chunks and bundles them - // in a separate chunk, similar to the vendor chunk - // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk - new webpack.optimize.CommonsChunkPlugin({ - name: 'entrance', - async: 'vendor-async', - children: true, - minChunks: 3 - }), - - // copy custom static assets - new CopyWebpackPlugin([ - { - from: path.resolve(__dirname, '../static'), - to: config.build.assetsSubDirectory, - ignore: ['*'] - }, - { - from: path.resolve(__dirname, '../src/components/chart'), - to: 'components', - ignore: ['.*'] - } - ]) - ] - }) -} + // copy custom static assets + new CopyWebpackPlugin([ + { + from: path.resolve(__dirname, '../static'), + to: config.build.assetsSubDirectory, + ignore: ['*'] + }, + { + from: path.resolve(__dirname, '../src/components/chart'), + to: 'components', + ignore: ['.*'] + } + ]) + ] +}) if (process.env.NODE_ENV == 'development') { webpackConfig.plugins.push( diff --git a/nezha-fronted/src/App.vue b/nezha-fronted/src/app/App.vue similarity index 100% rename from nezha-fronted/src/App.vue rename to nezha-fronted/src/app/App.vue diff --git a/nezha-fronted/index.html b/nezha-fronted/src/app/index.html similarity index 100% rename from nezha-fronted/index.html rename to nezha-fronted/src/app/index.html diff --git a/nezha-fronted/src/main.js b/nezha-fronted/src/app/main.js similarity index 86% rename from nezha-fronted/src/main.js rename to nezha-fronted/src/app/main.js index fd97ed842..fbd2d7829 100644 --- a/nezha-fronted/src/main.js +++ b/nezha-fronted/src/app/main.js @@ -4,29 +4,29 @@ import 'xterm/dist/xterm.css' import '@/assets/css/main.scss' import '@/assets/css/font/iconfont.js' import ElementUI from 'element-ui' -import i18n from './components/common/i18n' +import i18n from '@/components/common/i18n' import Vue from 'vue' import Vuex from 'vuex' -import store from './store/index' -import App from './App' -import router from './router' +import store from '@/store/index' +import App from '@/app/App' +import router from '@/router' import VueResource from 'vue-resource' import axios from 'axios' -import { hasPermission, hasButton } from './permission' +import { hasPermission, hasButton } from '@/permission' import loadsh from 'lodash' import plTable from 'pl-table' import 'pl-table/themes/index.css' -import { post, get, put, del } from './http.js' -import { clickoutside, bottomBoxWindow, stringTimeParseToUnix, unixTimeParseToString, chartResizeTool, tableSet, cancelWithChange, myLoading } from './components/common/js/tools.js' -import * as tools from './components/common/js/tools.js' -import * as constants from './components/common/js/constants.js' +import { post, get, put, del } from '@/http.js' +import { clickoutside, bottomBoxWindow, stringTimeParseToUnix, unixTimeParseToString, chartResizeTool, tableSet, cancelWithChange, myLoading } from '@/components/common/js/tools.js' +import * as tools from '@/components/common/js/tools.js' +import * as constants from '@/components/common/js/constants.js' -import Pagination from './components/common/pagination' // 引入全局分页组件 -import searchInput from './components/common/searchInput' // 搜索框组件 -import elementSet from './components/common/elementSet' // 自定义表头组件 -import MyElSelect from './components/common/elSelect/MyElSelect' +import Pagination from '@/components/common/pagination' // 引入全局分页组件 +import searchInput from '@/components/common/searchInput' // 搜索框组件 +import elementSet from '@/components/common/elementSet' // 自定义表头组件 +import MyElSelect from '@/components/common/elSelect/MyElSelect' import chartList from '@/components/chart/chartList.vue' // 全局引入 chartList 组件 防止 chart-group爆粗 import loading from '@/components/common/loading' diff --git a/nezha-fronted/src/components/common/js/validate.js b/nezha-fronted/src/components/common/js/validate.js index 695c01fda..26503f795 100644 --- a/nezha-fronted/src/components/common/js/validate.js +++ b/nezha-fronted/src/components/common/js/validate.js @@ -1,4 +1,4 @@ -import vm from '../../../main' +import vm from '../../../app/main' import lodash from 'lodash' // ipv4 ip校验 diff --git a/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue b/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue index add783d89..4bda2ee19 100644 --- a/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue +++ b/nezha-fronted/src/components/common/rightBox/editEndpointBoxNew.vue @@ -587,7 +587,7 @@ import pipelineSelect from './pipelineSelect' import selectWalk from '../popBox/selectWalk' import editRigthBox from '../mixin/editRigthBox' import VueTagsInput from '@johmun/vue-tags-input' -import vm from '@/main' +import vm from '@/app/main' export default { name: 'editEndpointBoxNew', diff --git a/nezha-fronted/src/components/common/rightBox/ipDetailsBox.vue b/nezha-fronted/src/components/common/rightBox/ipDetailsBox.vue index 12a256a63..06bd25e13 100644 --- a/nezha-fronted/src/components/common/rightBox/ipDetailsBox.vue +++ b/nezha-fronted/src/components/common/rightBox/ipDetailsBox.vue @@ -44,7 +44,7 @@