forked from doxas/twigl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
82 lines (77 loc) · 2.61 KB
/
webpack.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
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const FB_API_KEY = '<your environment>';
const FB_AUTH_DOMAIN = '<your environment>';
const FB_DATABASE_URL = '<your environment>';
const FB_PROJECT_ID = '<your environment>';
const FB_STORAGE_BUCKET = '<your environment>';
const FB_MESSAGING_SENDER_ID = '<your environment>';
// bitly api access token
let BITLY_ACCESS_TOKEN = '';
try {
BITLY_ACCESS_TOKEN = fs.readFileSync('./.bitly', {encoding: 'utf-8'});
} catch(err) {
console.log('[ERR] `.bitly` not found.');
}
console.log(BITLY_ACCESS_TOKEN);
module.exports = (env, argv) => {
let devmode;
let isDevelopment = argv.mode === 'development';
if(isDevelopment === true){
devmode = 'inline-source-map';
console.log('[OK] development build');
}else{
devmode = 'none';
console.log('[OK] production build');
}
return {
context: path.resolve(__dirname, 'src'),
entry: {
script: './script.js',
},
output: {
path: path.resolve(__dirname, 'public/js'),
publicPath: './',
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
presets: [
['@babel/env']
]
}
}]
}
]
},
devServer: {
contentBase: path.join(__dirname, 'public'),
openPage: './index.html',
open: true,
port: 9090,
publicPath: '/js/',
watchContentBase: true,
},
plugins: [
new webpack.DefinePlugin({
__FB_API_KEY__: JSON.stringify(FB_API_KEY),
__FB_AUTH_DOMAIN__: JSON.stringify(FB_AUTH_DOMAIN),
__FB_DATABASE_URL__: JSON.stringify(FB_DATABASE_URL),
__FB_PROJECT_ID__: JSON.stringify(FB_PROJECT_ID),
__FB_STORAGE_BUCKET__: JSON.stringify(FB_STORAGE_BUCKET),
__FB_MESSAGING_SENDER_ID__: JSON.stringify(FB_MESSAGING_SENDER_ID),
__BITLY_ACCESS_TOKEN__ : JSON.stringify(BITLY_ACCESS_TOKEN),
})
],
cache: true,
devtool: devmode,
};
};