Add all dashboard projects
This commit is contained in:
44
test/MES_Manage_View_V20/build/build.js
Normal file
44
test/MES_Manage_View_V20/build/build.js
Normal file
@@ -0,0 +1,44 @@
|
||||
require('./check-versions')()
|
||||
|
||||
process.env.NODE_ENV = 'production'
|
||||
|
||||
const ora = require('ora')
|
||||
const rm = require('rimraf')
|
||||
const path = require('path')
|
||||
const chalk = require('chalk')
|
||||
const webpack = require('webpack')
|
||||
const config = require('../config')
|
||||
const webpackConfig = require('./webpack.prod.conf')
|
||||
|
||||
const spinner = ora('building for production...')
|
||||
spinner.start()
|
||||
|
||||
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
||||
if (err) throw err
|
||||
webpack(webpackConfig, (err, stats) => {
|
||||
spinner.stop()
|
||||
if (err) throw err
|
||||
process.stdout.write(
|
||||
stats.toString({
|
||||
colors: true,
|
||||
modules: false,
|
||||
children: false,
|
||||
chunks: false,
|
||||
chunkModules: false
|
||||
}) + '\n\n'
|
||||
)
|
||||
|
||||
if (stats.hasErrors()) {
|
||||
console.log(chalk.red(' Build failed with errors.\n'))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log(chalk.cyan(' Build complete.\n'))
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
' Tip: built files are meant to be served over an HTTP server.\n' +
|
||||
" Opening index.html over file:// won't work.\n"
|
||||
)
|
||||
)
|
||||
})
|
||||
})
|
||||
63
test/MES_Manage_View_V20/build/check-versions.js
Normal file
63
test/MES_Manage_View_V20/build/check-versions.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const chalk = require('chalk')
|
||||
const semver = require('semver')
|
||||
const packageConfig = require('../package.json')
|
||||
const shell = require('shelljs')
|
||||
|
||||
function exec(cmd) {
|
||||
return require('child_process')
|
||||
.execSync(cmd)
|
||||
.toString()
|
||||
.trim()
|
||||
}
|
||||
|
||||
const versionRequirements = [
|
||||
{
|
||||
name: 'node',
|
||||
currentVersion: semver.clean(process.version),
|
||||
versionRequirement: packageConfig.engines.node
|
||||
}
|
||||
]
|
||||
|
||||
// if (shell.which('npm')) {
|
||||
// versionRequirements.push({
|
||||
// name: 'npm',
|
||||
// currentVersion: exec('npm --version'),
|
||||
// versionRequirement: packageConfig.engines.npm
|
||||
// })
|
||||
// }
|
||||
|
||||
module.exports = function() {
|
||||
const warnings = []
|
||||
|
||||
for (let i = 0; i < versionRequirements.length; i++) {
|
||||
const mod = versionRequirements[i]
|
||||
|
||||
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
|
||||
warnings.push(
|
||||
mod.name +
|
||||
': ' +
|
||||
chalk.red(mod.currentVersion) +
|
||||
' should be ' +
|
||||
chalk.green(mod.versionRequirement)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (warnings.length) {
|
||||
console.log('')
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'To use this template, you must update following to modules:'
|
||||
)
|
||||
)
|
||||
console.log()
|
||||
|
||||
for (let i = 0; i < warnings.length; i++) {
|
||||
const warning = warnings[i]
|
||||
console.log(' ' + warning)
|
||||
}
|
||||
|
||||
console.log()
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
BIN
test/MES_Manage_View_V20/build/logo.png
Normal file
BIN
test/MES_Manage_View_V20/build/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
99
test/MES_Manage_View_V20/build/utils.js
Normal file
99
test/MES_Manage_View_V20/build/utils.js
Normal file
@@ -0,0 +1,99 @@
|
||||
const path = require('path')
|
||||
const config = require('../config')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
|
||||
|
||||
const packageConfig = require('../package.json')
|
||||
exports.assetsPath = function(_path) {
|
||||
const assetsSubDirectory =
|
||||
process.env.NODE_ENV === 'production'
|
||||
? config.build.assetsSubDirectory
|
||||
: config.dev.assetsSubDirectory
|
||||
|
||||
return path.posix.join(assetsSubDirectory, _path)
|
||||
}
|
||||
exports.cssLoaders = function (options) {
|
||||
options = options || {}
|
||||
|
||||
const cssLoader = {
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
sourceMap: options.sourceMap,
|
||||
importLoaders: 2 // 确保 postcss 和 sass 加载器正常工作
|
||||
}
|
||||
}
|
||||
|
||||
const postcssLoader = {
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
sourceMap: options.sourceMap,
|
||||
postcssOptions: {
|
||||
plugins: [
|
||||
require('autoprefixer')()
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateLoaders(loader, loaderOptions) {
|
||||
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
|
||||
|
||||
if (loader) {
|
||||
loaders.push({
|
||||
loader: loader + '-loader',
|
||||
options: Object.assign({}, loaderOptions, {
|
||||
sourceMap: options.sourceMap
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (options.extract) {
|
||||
return [MiniCssExtractPlugin.loader].concat(loaders)
|
||||
} else {
|
||||
return ['vue-style-loader'].concat(loaders)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
css: generateLoaders(),
|
||||
postcss: generateLoaders(),
|
||||
less: generateLoaders('less'),
|
||||
sass: generateLoaders('sass', { indentedSyntax: true }),
|
||||
scss: generateLoaders('sass'),
|
||||
stylus: generateLoaders('stylus'),
|
||||
styl: generateLoaders('stylus')
|
||||
}
|
||||
}
|
||||
// Generate loaders for standalone style files (outside of .vue)
|
||||
exports.styleLoaders = function (options) {
|
||||
const output = []
|
||||
const loaders = exports.cssLoaders(options)
|
||||
|
||||
for (const extension in loaders) {
|
||||
const loader = loaders[extension]
|
||||
output.push({
|
||||
test: new RegExp('\\.' + extension + '$'),
|
||||
use: loader
|
||||
})
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
exports.createNotifierCallback = () => {
|
||||
const notifier = require('node-notifier')
|
||||
|
||||
return (severity, errors) => {
|
||||
if (severity !== 'error') return
|
||||
|
||||
const error = errors[0]
|
||||
const filename = error.file && error.file.split('!').pop()
|
||||
|
||||
notifier.notify({
|
||||
title: packageConfig.name,
|
||||
message: severity + ': ' + error.name,
|
||||
subtitle: filename || '',
|
||||
icon: path.join(__dirname, 'logo.png')
|
||||
})
|
||||
}
|
||||
}
|
||||
3
test/MES_Manage_View_V20/build/vue-loader.conf.js
Normal file
3
test/MES_Manage_View_V20/build/vue-loader.conf.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
//You can set the vue-loader configuration by yourself.
|
||||
}
|
||||
187
test/MES_Manage_View_V20/build/webpack.base.conf.js
Normal file
187
test/MES_Manage_View_V20/build/webpack.base.conf.js
Normal file
@@ -0,0 +1,187 @@
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
const utils = require('./utils')
|
||||
const config = require('../config')
|
||||
const webpack = require('webpack')
|
||||
const { VueLoaderPlugin } = require('vue-loader')
|
||||
const vueLoaderConfig = require('./vue-loader.conf')
|
||||
const { loader} = require('mini-css-extract-plugin')
|
||||
const ESLintPlugin = require('eslint-webpack-plugin');
|
||||
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, '..', dir)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
context: path.resolve(__dirname, '../'),
|
||||
entry: {
|
||||
app: './src/main.js'
|
||||
},
|
||||
output: {
|
||||
path: config.build.assetsRoot,
|
||||
filename: '[name].js',
|
||||
publicPath: process.env.NODE_ENV === 'production'
|
||||
? config.build.assetsPublicPath
|
||||
: config.dev.assetsPublicPath,
|
||||
clean: true // 替代 CleanWebpackPlugin
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.vue', '.json'],
|
||||
alias: {
|
||||
'@': resolve('src'),
|
||||
'vue$': 'vue/dist/vue.esm.js'
|
||||
},
|
||||
fallback: {
|
||||
"process": require.resolve("process/browser.js"),
|
||||
"path": require.resolve("path-browserify"),
|
||||
"crypto": require.resolve("crypto-browserify"),
|
||||
"stream": require.resolve("stream-browserify"),
|
||||
"buffer": require.resolve("buffer"),
|
||||
"util": require.resolve("util"),
|
||||
"fs": false,
|
||||
"tls": false,
|
||||
"net": false,
|
||||
"http": false,
|
||||
"https": false,
|
||||
"zlib": false
|
||||
}
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'vue-loader',
|
||||
options: vueLoaderConfig
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
exclude: /node_modules/,
|
||||
include: [
|
||||
resolve('src'),
|
||||
resolve('test'),
|
||||
resolve('node_modules/webpack-dev-server/client')
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.svg$/,
|
||||
loader: 'svg-sprite-loader',
|
||||
include: [resolve('src/icons')],
|
||||
options: {
|
||||
symbolId: 'icon-[name]'
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif|webp)(\?.*)?$/,
|
||||
type: 'asset',
|
||||
parser: {
|
||||
dataUrlCondition: {
|
||||
maxSize: 10 * 1024 // 10kb
|
||||
}
|
||||
},
|
||||
generator: {
|
||||
filename: utils.assetsPath('img/[name].[hash:8][ext]')
|
||||
},
|
||||
exclude: [resolve('src/icons')]
|
||||
},
|
||||
{
|
||||
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
|
||||
type: 'asset',
|
||||
parser: {
|
||||
dataUrlCondition: {
|
||||
maxSize: 10 * 1024
|
||||
}
|
||||
},
|
||||
generator: {
|
||||
filename: utils.assetsPath('media/[name].[hash:8][ext]')
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
||||
type: 'asset',
|
||||
parser: {
|
||||
dataUrlCondition: {
|
||||
maxSize: 10 * 1024
|
||||
}
|
||||
},
|
||||
generator: {
|
||||
filename: utils.assetsPath('fonts/[name].[hash:8][ext]')
|
||||
}
|
||||
},
|
||||
// 添加 CSS 文件处理规则
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
process.env.NODE_ENV === 'production'
|
||||
? loader
|
||||
: 'vue-style-loader',
|
||||
'css-loader'
|
||||
],
|
||||
include: /node_modules/ // 专门处理 node_modules 中的 CSS
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
process.env.NODE_ENV === 'production'
|
||||
? loader
|
||||
: 'vue-style-loader',
|
||||
'css-loader'
|
||||
],
|
||||
exclude: /node_modules/ // 处理项目中的 CSS
|
||||
},
|
||||
// SCSS 规则
|
||||
{
|
||||
test: /\.scss$/,
|
||||
use: [
|
||||
process.env.NODE_ENV === 'production'
|
||||
? loader
|
||||
: 'vue-style-loader',
|
||||
'css-loader',
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
// 使用现代 API
|
||||
api: 'modern',
|
||||
// 或者使用兼容模式
|
||||
// api: 'legacy',
|
||||
sassOptions: {
|
||||
// 其他 Sass 选项
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.sass$/,
|
||||
use: [
|
||||
process.env.NODE_ENV === 'production'
|
||||
? loader
|
||||
: 'vue-style-loader',
|
||||
'css-loader',
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sassOptions: {
|
||||
indentedSyntax: true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new VueLoaderPlugin(),
|
||||
new webpack.ProvidePlugin({
|
||||
process: 'process/browser.js',
|
||||
Buffer: ['buffer', 'Buffer']
|
||||
}),
|
||||
// new ESLintPlugin({
|
||||
// extensions: ['js', 'vue'],
|
||||
// exclude: 'node_modules',
|
||||
// fix: false, // 可选:自动修复
|
||||
// emitWarning: false, // 显示警告
|
||||
// failOnError: false // 错误时不停止构建
|
||||
// })
|
||||
]
|
||||
}
|
||||
107
test/MES_Manage_View_V20/build/webpack.dev.conf.js
Normal file
107
test/MES_Manage_View_V20/build/webpack.dev.conf.js
Normal file
@@ -0,0 +1,107 @@
|
||||
'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')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const ESLintPlugin = require('eslint-webpack-plugin')
|
||||
const portfinder = require('portfinder')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, '..', dir)
|
||||
}
|
||||
|
||||
|
||||
const devWebpackConfig = merge(baseWebpackConfig, {
|
||||
mode: 'development',
|
||||
stats: 'errors-warnings',
|
||||
infrastructureLogging: {
|
||||
level: 'warn'
|
||||
},
|
||||
devtool: 'eval-cheap-module-source-map',
|
||||
cache: {
|
||||
type: 'filesystem',
|
||||
buildDependencies: {
|
||||
config: [__filename]
|
||||
}
|
||||
},
|
||||
devServer: {
|
||||
https: true,
|
||||
historyApiFallback: true,
|
||||
hot: true,
|
||||
compress: true,
|
||||
host: process.env.HOST || config.dev.host,
|
||||
port: process.env.PORT || config.dev.port,
|
||||
open: config.dev.autoOpenBrowser,
|
||||
static: {
|
||||
publicPath: config.dev.assetsPublicPath,
|
||||
watch: true
|
||||
},
|
||||
client: {
|
||||
logging: 'warn',
|
||||
overlay: config.dev.errorOverlay ? { errors: true, warnings: false } : false
|
||||
},
|
||||
proxy: config.dev.proxyTable
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ProgressPlugin({
|
||||
activeModules: true, // 设置为 true 会显示当前正在处理的模块,但可能会影响性能
|
||||
entries: true, // 显示条目计数
|
||||
handler: (percentage, message, ...args) => {
|
||||
// 一个简单的自定义处理函数,输出到控制台
|
||||
console.log(`构建进度: ${(percentage * 100).toFixed(2)}% ${message}`);
|
||||
}
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': require('../config/dev.env')
|
||||
}),
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.build.assetsSubDirectory,
|
||||
globOptions: {
|
||||
ignore: ['.*']
|
||||
}
|
||||
}
|
||||
]
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
filename: 'index.html',
|
||||
template: 'index.html',
|
||||
inject: true,
|
||||
favicon: resolve('favicon.ico'),
|
||||
title: '数据分析处理平台',
|
||||
BASE_URL: 'static'
|
||||
}),
|
||||
...(config.dev.useEslint ? [new ESLintPlugin({
|
||||
extensions: ['js', 'vue'],
|
||||
formatter: require('eslint-friendly-formatter'),
|
||||
emitWarning: !config.dev.showEslintErrorsInOverlay
|
||||
})] : [])
|
||||
],
|
||||
optimization: {
|
||||
removeAvailableModules: false,
|
||||
removeEmptyChunks: false,
|
||||
splitChunks: false,
|
||||
minimize: false
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = new Promise((resolve, reject) => {
|
||||
portfinder.basePort = process.env.PORT || config.dev.port
|
||||
portfinder.getPort((err, port) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
devWebpackConfig.devServer.port = port
|
||||
process.env.PORT = port
|
||||
|
||||
console.log(`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`)
|
||||
resolve(devWebpackConfig)
|
||||
}
|
||||
})
|
||||
})
|
||||
133
test/MES_Manage_View_V20/build/webpack.prod.conf.js
Normal file
133
test/MES_Manage_View_V20/build/webpack.prod.conf.js
Normal file
@@ -0,0 +1,133 @@
|
||||
'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')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
|
||||
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, '..', dir)
|
||||
}
|
||||
|
||||
const env = require('../config/prod.env')
|
||||
|
||||
const webpackConfig = merge(baseWebpackConfig, {
|
||||
mode: 'production',
|
||||
devtool: config.build.productionSourceMap ? config.build.devtool : false,
|
||||
output: {
|
||||
path: config.build.assetsRoot,
|
||||
filename: utils.assetsPath('js/[name].[contenthash:8].js'),
|
||||
chunkFilename: utils.assetsPath('js/[name].[contenthash:8].chunk.js'),
|
||||
publicPath: config.build.assetsPublicPath
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': env
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: utils.assetsPath('css/[name].[contenthash:8].css'),
|
||||
chunkFilename: utils.assetsPath('css/[name].[contenthash:8].css')
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
filename: config.build.index,
|
||||
template: 'index.html',
|
||||
inject: true,
|
||||
favicon: resolve('favicon.ico'),
|
||||
title: '信息管理系统',
|
||||
minify: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
removeAttributeQuotes: true,
|
||||
minifyCSS: true,
|
||||
minifyJS: true
|
||||
}
|
||||
}),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: path.resolve(__dirname, '../static'),
|
||||
to: config.build.assetsSubDirectory,
|
||||
globOptions: {
|
||||
ignore: ['.*']
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
],
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
parallel: true,
|
||||
terserOptions: {
|
||||
compress: {
|
||||
drop_console: true
|
||||
}
|
||||
}
|
||||
}),
|
||||
new CssMinimizerPlugin()
|
||||
],
|
||||
splitChunks: {
|
||||
chunks: 'all',
|
||||
cacheGroups: {
|
||||
libs: {
|
||||
name: 'chunk-libs',
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
priority: 10,
|
||||
chunks: 'initial'
|
||||
},
|
||||
elementUI: {
|
||||
name: 'chunk-elementUI',
|
||||
priority: 20,
|
||||
test: /[\\/]node_modules[\\/]element-ui[\\/]/
|
||||
},
|
||||
commons: {
|
||||
name: 'chunk-commons',
|
||||
test: resolve('src/components'),
|
||||
minChunks: 3,
|
||||
priority: 5,
|
||||
reuseExistingChunk: true
|
||||
}
|
||||
}
|
||||
},
|
||||
runtimeChunk: {
|
||||
name: 'runtime'
|
||||
}
|
||||
},
|
||||
performance: {
|
||||
hints: 'warning',
|
||||
maxEntrypointSize: 512000,
|
||||
maxAssetSize: 512000
|
||||
}
|
||||
})
|
||||
|
||||
if (config.build.productionGzip) {
|
||||
const CompressionWebpackPlugin = require('compression-webpack-plugin')
|
||||
webpackConfig.plugins.push(
|
||||
new CompressionWebpackPlugin({
|
||||
filename: '[path][base].gz',
|
||||
algorithm: 'gzip',
|
||||
test: new RegExp(`\\.(${config.build.productionGzipExtensions.join('|')})$`),
|
||||
threshold: 10240,
|
||||
minRatio: 0.8
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
if (config.build.bundleAnalyzerReport) {
|
||||
webpackConfig.plugins.push(
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerPort: 8888
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = webpackConfig
|
||||
Reference in New Issue
Block a user