forked from egoist/codepan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
poi.config.js
75 lines (70 loc) · 2.08 KB
/
poi.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
const nodeModules = require('webpack-node-modules')
const repoLatestCommit = require('repo-latest-commit')
const pkg = require('./package')
const cdns = {
BABEL_CDN: 'https://cdn.jsdelivr.net/npm/@babel/[email protected]/babel.min.js',
PUG_CDN: 'https://cdn.jsdelivr.net/npm/[email protected]/index.js',
CSSNEXT_CDN: 'https://cdn.jsdelivr.net/npm/[email protected]/index.js',
POSTCSS_CDN: 'https://cdn.jsdelivr.net/npm/[email protected]/index.js',
TYPESCRIPT_CDN: 'https://cdn.jsdelivr.net/npm/[email protected]/index.js'
}
module.exports = {
extendWebpack(config) {
config.module.set('noParse', /babel-preset-vue/)
config.module.rule('js')
.include
.add(nodeModules())
config.node.set('fs', 'empty')
config.externals({
electron: 'commonjs electron'
})
},
production: {
sourceMap: false
},
hash: false,
homepage: '/',
env: Object.assign({
VERSION: `v${pkg.version}-${repoLatestCommit().commit.slice(0, 7)}`,
LATEST_COMMIT: repoLatestCommit().commit.slice(0, 7)
}, cdns),
presets: [
require('poi-preset-bundle-report')(),
require('poi-preset-babel-minify')(),
require('poi-preset-offline')({
pluginOptions: {
version: '[hash]',
autoUpdate: true,
safeToUseOptionalCaches: true,
caches: {
main: ['index.html', 'client.*', 'vendor.*', 'editor-page.chunk.js'],
additional: ['*.chunk.js', ':externals:'],
optional: [':rest:']
},
ServiceWorker: {
events: true,
navigateFallbackURL: '/'
},
AppCache: {
events: true,
FALLBACK: { '/': '/' }
},
externals: [].concat(Object.keys(cdns).reduce((res, name) => {
return res.concat(cdns[name])
}, []))
}
})
],
babel: {
babelrc: false,
presets: [
require.resolve('babel-preset-poi')
],
plugins: [[require.resolve('babel-plugin-component'), [
{
libraryName: 'element-ui',
styleLibraryName: 'theme-chalk'
}
]]]
}
}