forked from dcloudio/uni-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
69 lines (58 loc) · 2.05 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
const path = require('path')
const resolve = dir => path.resolve(__dirname, '../', dir)
const pkgPath = resolve('package.json')
const { splitMediaPlugin, generateMediaQuerys } = require('./postcssSplitMediaPlugin')
const webpack = require('webpack')
const webpackConfig = require('./webpack.config.js')
const postCssConfig = require('../postcss.config')
let outputDir = resolve('./packages/uni-' + process.env.UNI_PLATFORM + '/dist')
if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_UI === 'true') {
outputDir = resolve('./packages/uni-' + process.env.UNI_PLATFORM + '-ui/dist')
}
if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_VIEW === 'true') {
outputDir = resolve('./packages/uni-' + process.env.UNI_PLATFORM + '/dist')
}
if (process.env.UNI_PLATFORM === 'h5') { postCssConfig.plugins.push(splitMediaPlugin) }
module.exports = {
publicPath: '/',
outputDir,
lintOnSave: true, // or error
runtimeCompiler: false,
transpileDependencies: ['@dcloudio/uni-i18n'],
productionSourceMap: false,
configureWebpack: webpackConfig,
parallel: process.env.UNI_PLATFORM !== 'h5' || process.env.UNI_WATCH !== 'false' || process.env.UNI_UI === 'true',
chainWebpack: config => {
config.devtool('source-map')
config.module
.rule('eslint')
.include
.add(resolve('src'))
.add(resolve('lib/' + process.env.UNI_PLATFORM))
.end()
.use('eslint-loader')
.loader(resolve('node_modules/eslint-loader'))
.options({
fix: true,
configFile: pkgPath
})
config.plugins.delete('hmr') // remove hot module reload
if (process.env.UNI_PLATFORM === 'h5') {
config
.plugin('webpack-build-done')
.use(webpack.ProgressPlugin, [function (percentage, message, ...args) {
if (percentage === 1) {
generateMediaQuerys({
outputDir
})
}
}])
}
},
css: {
extract: true,
loaderOptions: {
postcss: postCssConfig
}
}
}