-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
48 lines (44 loc) · 1.68 KB
/
webpack.config.js
File metadata and controls
48 lines (44 loc) · 1.68 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
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const webpack = require('webpack')
module.exports = (env, options) => {
const { DEV } = env // From webpack environment variable
if (DEV) { // Set env variable file by development state
require('dotenv').config({path: './dev.env'}) // Development state
} else {
require('dotenv').config({path: './.env'}) // Production state
}
console.log('process.env.API_SERVER :>> ', process.env.API_SERVER); // Logging value from env variable file
return {
mode: 'development', // 'production', 'development'
// entry: [
// './js/index.js',
// './js/index_2.js'
// ], // Start point
entry: './js/index.js', // Start point
output: { // Set output path of bundled file
path: path.resolve(__dirname, 'dist'), // Output path
filename: 'bundle.js' // Output file name
},
devServer: { // Dev server option
port: 3002, // Port
writeToDisk: true
},
plugins: [ // Webpack plugins
new HtmlWebpackPlugin({ // Apply html-webpack-plugin
template: path.resolve(__dirname, 'index.html'), // From template path
filename: path.resolve(__dirname, 'dist/index.html'), // Create template path
inject: true // Inject bundled js file (default set: true)
}),
new webpack.DefinePlugin({
DEVELOPMENT: env.DEV ? "true" : "false",
API_SERVER_HOST: env.DEV ? process.env.API_SERVER : ""
// API_SERVER_HOST: env.DEV ? JSON.stringify(process.env.API_SERVER) : ""
}),
// new webpack.EnvironmentPlugin(['DEBUG'])
],
optimization: { // Optimization
minimize: false // No minify
}
}
}