-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
94 lines (89 loc) · 2.24 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
82
83
84
85
86
87
88
89
90
91
92
93
94
const DotEnv = require('dotenv');
const path = require('path');
// const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
// const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');
DotEnv.config({ path: `${__dirname}/.env` });
const dotEnv = new webpack.DefinePlugin({
'process.env': {
BASE_URL: JSON.stringify(process.env.BASE_URL),
CLOUDINARY_CLOUD_NAME: JSON.stringify(process.env.CLOUDINARY_CLOUD_NAME),
CLOUDINARY_API_KEY: JSON.stringify(process.env.CLOUDINARY_API_KEY),
CLOUDINARY_API_SECRET: JSON.stringify(process.env.CLOUDINARY_API_SECRET)
}
});
// const htmlWebpackPlugin = new HtmlWebpackPlugin({
// template: 'client/src/index.html'
// });
const extractPlugin = new ExtractTextPlugin({
filename: 'secondary.css'
});
// const DIST_DIR = path.resolve(__dirname, 'dist');
const SRC_DIR = path.resolve(__dirname, 'client/src');
const config = {
node: {
fs: 'empty'
},
entry: { main: path.join(SRC_DIR, '/WeconnectRoot.js') },
output: {
path: '/',
filename: 'bundle.js',
// publicPath: '/'
},
module: {
// loaders
rules: [
{
test: /\.jsx?$/,
include: SRC_DIR,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['env', 'stage-2', 'react']
}
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: { minimize: true }
}
]
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.css$/,
use: extractPlugin.extract({
fallback: 'style-loader', use: ['url-loader']
})
},
{
test: /\.svg$/,
loader: 'svg-url-loader',
options: { noquotes: true }
},
{
test: /\.(png|jpg|gif|jpeg|eot|ttf|woff|woff2|svg)$/,
exclude: /node_modules/,
use: {
loader: 'url-loader'
}
}
]
},
resolve: {
extensions: ['.js', '.jsx']
},
plugins: [
extractPlugin,
dotEnv,
// htmlWebpackPlugin
]
};
module.exports = config;