2019-11-28 18:23:49 +08:00
|
|
|
'use strict'
|
|
|
|
|
const path = require('path')
|
|
|
|
|
const utils = require('./utils')
|
|
|
|
|
const config = require('../config')
|
|
|
|
|
const vueLoaderConfig = require('./vue-loader.conf')
|
2022-11-16 11:17:31 +08:00
|
|
|
// const VueLoaderPlugin = require('vue-loader/lib/plugin')
|
2022-05-05 18:22:18 +08:00
|
|
|
const arg = process.env.BUILD_MODE
|
|
|
|
|
const devStart = process.env.npm_lifecycle_event
|
2019-11-28 18:23:49 +08:00
|
|
|
function resolve (dir) {
|
|
|
|
|
return path.join(__dirname, '..', dir)
|
|
|
|
|
}
|
2022-05-05 18:22:18 +08:00
|
|
|
const baseConfig = {
|
2019-11-28 18:23:49 +08:00
|
|
|
context: path.resolve(__dirname, '../'),
|
|
|
|
|
entry: {
|
2022-05-05 18:22:18 +08:00
|
|
|
app: './src/entrance/app/main.js',
|
|
|
|
|
exportHtml: './src/entrance/exportHtml/exportHtml.js'
|
2019-11-28 18:23:49 +08:00
|
|
|
},
|
|
|
|
|
output: {
|
|
|
|
|
path: config.build.assetsRoot,
|
|
|
|
|
filename: '[name].js',
|
|
|
|
|
publicPath: process.env.NODE_ENV === 'production'
|
|
|
|
|
? config.build.assetsPublicPath
|
|
|
|
|
: config.dev.assetsPublicPath
|
|
|
|
|
},
|
|
|
|
|
resolve: {
|
|
|
|
|
extensions: ['.js', '.vue', '.json'],
|
|
|
|
|
alias: {
|
2021-04-28 15:18:21 +08:00
|
|
|
vue$: 'vue/dist/vue.esm.js',
|
|
|
|
|
'@': resolve('src')
|
2019-11-28 18:23:49 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
test: /\.vue$/,
|
|
|
|
|
loader: 'vue-loader',
|
|
|
|
|
options: vueLoaderConfig
|
2023-10-08 18:31:55 +08:00
|
|
|
}, {
|
2022-12-21 14:05:37 +08:00
|
|
|
test: /\.less$/,
|
|
|
|
|
use: [
|
|
|
|
|
'vue-style-loader',
|
|
|
|
|
'css-loader',
|
|
|
|
|
'less-loader'
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.js$/,
|
|
|
|
|
loader: 'babel-loader',
|
|
|
|
|
exclude: file => (
|
|
|
|
|
/node_modules/.test(file) &&
|
|
|
|
|
!/\.vue\.js/.test(file)
|
|
|
|
|
)
|
2019-11-28 18:23:49 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-04-28 15:18:21 +08:00
|
|
|
test: /\.(js)$/,
|
2022-11-08 17:49:27 +08:00
|
|
|
loader: 'babel-loader',
|
2021-12-21 14:25:13 +08:00
|
|
|
include: [
|
|
|
|
|
resolve('src'),
|
|
|
|
|
resolve('test'),
|
|
|
|
|
resolve('node_modules/element-ui/packages/scrollbar'),
|
|
|
|
|
resolve('node_modules/@interactjs'),
|
2023-10-08 18:31:55 +08:00
|
|
|
resolve('node_modules/vue-grid-layout'),
|
|
|
|
|
resolve('node_modules/pl-table/package'),
|
2023-10-11 15:44:41 +08:00
|
|
|
resolve('node_modules/uplot')
|
2021-12-21 14:25:13 +08:00
|
|
|
],
|
2021-04-28 15:18:21 +08:00
|
|
|
exclude: '/node_modules/',
|
2022-11-08 17:49:27 +08:00
|
|
|
options: {
|
2023-10-09 11:53:00 +08:00
|
|
|
presets: ['@babel/preset-env', '@vue/babel-preset-jsx']
|
2022-11-08 17:49:27 +08:00
|
|
|
}
|
2019-11-28 18:23:49 +08:00
|
|
|
},
|
2023-10-11 15:44:41 +08:00
|
|
|
{
|
|
|
|
|
test: /\.ts$/,
|
|
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'babel-loader',
|
|
|
|
|
options: {
|
|
|
|
|
presets: ['@babel/preset-env']
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'ts-loader'
|
|
|
|
|
],
|
|
|
|
|
include: [
|
|
|
|
|
resolve('node_modules/monaco-editor')
|
|
|
|
|
],
|
|
|
|
|
exclude: /node_modules/
|
|
|
|
|
},
|
2019-11-28 18:23:49 +08:00
|
|
|
{
|
|
|
|
|
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
|
|
|
|
loader: 'url-loader',
|
|
|
|
|
options: {
|
|
|
|
|
limit: 10000,
|
|
|
|
|
name: utils.assetsPath('img/[name].[hash:7].[ext]')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
|
|
|
|
|
loader: 'url-loader',
|
|
|
|
|
options: {
|
|
|
|
|
limit: 10000,
|
|
|
|
|
name: utils.assetsPath('media/[name].[hash:7].[ext]')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
|
|
|
|
loader: 'url-loader',
|
|
|
|
|
options: {
|
|
|
|
|
limit: 10000,
|
|
|
|
|
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
|
|
|
|
|
}
|
2022-12-21 14:05:37 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.pug$/,
|
|
|
|
|
oneOf: [
|
|
|
|
|
// this applies to `<template lang="pug">` in Vue components
|
|
|
|
|
{
|
|
|
|
|
resourceQuery: /^\?vue/,
|
|
|
|
|
use: ['pug-plain-loader']
|
|
|
|
|
},
|
|
|
|
|
// this applies to pug imports inside JavaScript
|
|
|
|
|
{
|
|
|
|
|
use: ['raw-loader', 'pug-plain-loader']
|
|
|
|
|
}
|
|
|
|
|
]
|
2023-03-30 11:50:43 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.js$/,
|
|
|
|
|
exclude: /node_modules/,
|
|
|
|
|
use: ['cache-loader', 'babel-loader']
|
2019-11-28 18:23:49 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
2022-11-16 11:17:31 +08:00
|
|
|
// plugins: [
|
|
|
|
|
// new VueLoaderPlugin()
|
|
|
|
|
// ],
|
2019-11-28 18:23:49 +08:00
|
|
|
node: {
|
|
|
|
|
// prevent webpack from injecting useless setImmediate polyfill because Vue
|
|
|
|
|
// source contains it (although only uses it if it's native).
|
|
|
|
|
setImmediate: false,
|
|
|
|
|
// prevent webpack from injecting mocks to Node native modules
|
|
|
|
|
// that does not make sense for the client
|
|
|
|
|
dgram: 'empty',
|
|
|
|
|
fs: 'empty',
|
|
|
|
|
net: 'empty',
|
|
|
|
|
tls: 'empty',
|
|
|
|
|
child_process: 'empty'
|
2022-05-05 18:22:18 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (arg === 'html' || devStart === 'dev:html') {
|
|
|
|
|
delete baseConfig.entry.app
|
|
|
|
|
baseConfig.module.rules.unshift({
|
|
|
|
|
include: [
|
|
|
|
|
resolve('src/entrance/app'),
|
|
|
|
|
resolve('src/components/common/bottomBox'),
|
|
|
|
|
resolve('src/components/common/detailView'),
|
|
|
|
|
resolve('src/components/common/elSelect'),
|
|
|
|
|
resolve('src/components/common/filterSearch'),
|
|
|
|
|
resolve('src/components/common/globalSearch'),
|
|
|
|
|
resolve('src/components/common/honeycomb'),
|
|
|
|
|
resolve('src/components/common/myDatePicker'),
|
|
|
|
|
resolve('src/components/common/overView'),
|
|
|
|
|
resolve('src/components/common/popBox'),
|
|
|
|
|
resolve('src/components/common/project'),
|
|
|
|
|
resolve('src/components/common/rightBox'),
|
|
|
|
|
resolve('src/components/common/table'),
|
2023-10-08 18:31:55 +08:00
|
|
|
resolve('src/components/common/v-selectpagenew')
|
2022-09-13 18:00:56 +08:00
|
|
|
// resolve('src/components/page')
|
2022-05-05 18:22:18 +08:00
|
|
|
],
|
|
|
|
|
loader: 'url-loader',
|
|
|
|
|
options: {
|
|
|
|
|
limit: 10,
|
|
|
|
|
generator: (content, mimetype, encoding, resourcePath) => {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else if (arg === 'app' || devStart === 'dev') {
|
|
|
|
|
delete baseConfig.entry.exportHtml
|
|
|
|
|
baseConfig.module.rules.unshift({
|
|
|
|
|
include: [
|
|
|
|
|
resolve('src/entrance/exportHtml')
|
|
|
|
|
],
|
|
|
|
|
loader: 'url-loader',
|
|
|
|
|
options: {
|
|
|
|
|
limit: 10,
|
|
|
|
|
generator: (content, mimetype, encoding, resourcePath) => {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2019-11-28 18:23:49 +08:00
|
|
|
}
|
2023-10-08 18:31:55 +08:00
|
|
|
module.exports = {
|
2023-10-11 15:44:41 +08:00
|
|
|
...baseConfig
|
2023-10-08 18:31:55 +08:00
|
|
|
// transpileDependencies: ['uplot']
|
|
|
|
|
}
|