-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvue.config.js
105 lines (88 loc) · 3 KB
/
vue.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
const DEVELOPMENT = process.env.NODE_ENV == 'development'
const PRODUCTION = process.env.NODE_ENV == 'production'
const DEBUG = false
const fs = require('fs')
const path = require('path')
const _ = require('lodash')
const dotenv = require('dotenv')
const webpack = require('webpack')
const package = require('./package.json')
const tailwindcss = require('tailwindcss')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports = {
outputDir: 'dist/client',
runtimeCompiler: true,
// css: { sourceMap: !!process.env.DEVELOPMENT },
configureWebpack: function (config) {
if (DEBUG) console.log('configure config ->', config)
delete config.node.process
config.output.filename = '[name].bundle.js'
config.output.chunkFilename = '[name].chunk.js'
if (DEVELOPMENT) {
// config.devtool = 'source-map'
config.plugins.push(
new webpack.WatchIgnorePlugin([
/node_modules/,
/dist/,
/server/,
/assets/,
/public/,
/env/,
/json/,
]),
)
// config.module.rules.filter(rule => Array.isArray(rule.use)).forEach(function(rule) {
// rule.use.filter(use => use.loader == 'url-loader').forEach(function(use) {
// use.loader = 'file-loader'
// delete use.options.limit
// })
// })
}
// config.plugins.push(tailwindcss(path.join(__dirname, 'src/client/styles/tailwind.js')))
// config.plugins.push(new webpack.ProvidePlugin({ Promise: 'zousan/src/zousan' }))
// config.plugins.push(new BundleAnalyzerPlugin())
},
chainWebpack: function (config) {
if (DEBUG) console.log('chain config ->', config)
let main = path.join(__dirname, 'src/client/main.ts')
config.entry('app').clear().add(main)
config.resolve.alias.store.delete('@')
config.plugin('define').tap(function (args) {
args[0]['process.env'].CLIENT = `"${true}"`
args[0]['process.env'][process.env.NODE_ENV.toUpperCase()] = `"${true}"`
args[0]['process.env'].NAME = `"${package.name}"`
args[0]['process.env'].VERSION = `"${package.version}"`
args[0]['process.env'].DOMAIN = `"${(DEVELOPMENT ? 'dev.' : '') + package.domain}"`
let env = dotenv.config({ path: path.join(__dirname, 'env/client.env') }).parsed || {}
Object.assign(
env,
dotenv.config({
path: path.join(__dirname, 'env/client.' + process.env.NODE_ENV + '.env'),
}).parsed || {},
)
Object.keys(env).forEach((k) => (args[0]['process.env'][k] = `"${env[k]}"`))
return args
})
config.plugin('fork-ts-checker').tap(function (args) {
args[0].tsconfig = '.client.tsconfig.json'
args[0].memoryLimit = 4096
args[0].workers = 2
return args
})
config.plugins.delete('no-emit-on-errors')
if (PRODUCTION) {
config.plugin('friendly-errors').tap(function (args) {
args[0].clearConsole = false
return args
})
}
},
}
if (DEBUG && !PRODUCTION) {
const inspector = require('inspector')
inspector.open(+process.debugPort - 1)
console.clear()
require('exit-hook')(inspector.close)
}