-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatic.config.js
More file actions
84 lines (83 loc) · 2.46 KB
/
Copy pathstatic.config.js
File metadata and controls
84 lines (83 loc) · 2.46 KB
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
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
require('https').globalAgent.options.ca = require('ssl-root-cas/latest').create();
const axios = require('axios')
export default {
webpack: (config, { defaultLoaders }) => {
config.module.rules = [{
oneOf: [
defaultLoaders.jsLoader,
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.svg$/,
use: [
"babel-loader",
{
loader: "react-svg-loader",
options: {
svgo: {
plugins: [
{ removeTitle: false }
],
floatPrecision: 2
}
}
}
]
},
defaultLoaders.fileLoader,
]
}]
if(Object.getPrototypeOf(config.plugins[config.plugins.length - 1]).constructor.name === "UglifyJsPlugin"){
console.log("ตรวจพบการใช้ปลั๊กอินหัวควย กำลังเปลี่ยนปลั๊กอินโดยอัตโนมัติ...")
config.plugins[config.plugins.length - 1] = new UglifyJSPlugin()
}
config.plugins.push(new ExtractTextPlugin("styles.css"))
return config;
},
getSiteData: () => ({
title: 'React Static',
}),
getRoutes: async () => ([
{
path: '/',
component: 'src/containers/Home',
},
{
path: '/VIC2017',
component: 'src/containers/camp_history/VIC_2017',
},
{
path: '/VIC2018',
component: 'src/containers/camp_history/VIC_2018',
},
{
path: '/about',
component: 'src/containers/About',
},
{
path: '/article/1',
component: 'src/containers/article/1',
},
{
path: '/register',
component: 'src/containers/Registration',
getData: async () => {
const formID = "e89bd2e072932eb6ab1b21073b9fc0fd160dace96b8d0cc12346ae5c95e54a9e"
const { data: result } = await axios.get(`http://datanaliez.com/api/v1/form/info/${formID}`)
const formData = {...result.result}
return {formData, formID}
}
},
{
is404: true,
component: 'src/containers/404',
},
])
}