-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpoi.config.js
51 lines (48 loc) · 1.27 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
const RenameWebpackPlugin = require('rename-webpack-plugin')
const { name, description } = require('./package.json')
const OfflinePlugin = require('offline-plugin')
const config = require('./config')
class GithubPagesWebpackPlugin {
apply (compiler) {
compiler.plugin('emit', (compilation, callback) => {
compilation.assets['404.html'] = compilation.assets['index.html']
callback()
})
}
}
const RELEASE_TIME = Date.now()
module.exports = (options, req) => ({
port: 80,
entry: './src/main.js',
env: {
RELEASE_TIME,
...config
},
babel: {
cacheDirectory: true,
presets: [
[require.resolve('babel-preset-poi'), { jsx: 'react' }]
]
},
presets: [
require('poi-preset-react')()
],
webpack (config) {
config.plugins.push(new RenameWebpackPlugin({
originNameReg: /locales\/(.*)\/(.*)\.json/g,
targetName: `locales/$1/$2.${RELEASE_TIME}.json`
}))
config.plugins.push(new GithubPagesWebpackPlugin())
config.plugins.push(new OfflinePlugin())
return config
},
html: {
title: `${name.replace(/[a-z]/, str => str.toUpperCase())} - ${description}`,
template: './static/index.html',
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
minifyJS: true
}
}
})