forked from takahashigroup/CADS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.base.config.js
More file actions
142 lines (139 loc) · 4.82 KB
/
webpack.base.config.js
File metadata and controls
142 lines (139 loc) · 4.82 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*=================================================================================================
// Project: CADS/MADS - An Integrated Web-based Visual Platform for Materials Informatics
// Hokkaido University (2018)
// ________________________________________________________________________________________________
// Authors: Jun Fujima (Former Lead Developer) [2018-2021]
// Mikael Nicander Kuwahara (Current Lead Developer) [2021-]
// ________________________________________________________________________________________________
// Description: Settings for webpacks static module bundler for this app
// ------------------------------------------------------------------------------------------------
// Notes: This is the base config that is used by all various deployments
// ------------------------------------------------------------------------------------------------
// References: 'NodeJS' platform and 'WebPack' library
=================================================================================================*/
//-------------------------------------------------------------------------------------------------
// Load required libraries
//-------------------------------------------------------------------------------------------------
const path = require('path');
const webpack = require('webpack');
const nodeModulesDir = path.resolve(__dirname, 'node_modules');
const BundleTracker = require('webpack-bundle-tracker');
//-------------------------------------------------------------------------------------------------
// Module Exports Webpack Bundle control Info
//-------------------------------------------------------------------------------------------------
module.exports = [
{
entry: ['./assets/js/common-index.js'],
output: {
path: path.resolve('./assets/bundles/'),
filename: 'bundle-common.js',
},
name: 'common',
module: {
rules: [
{
test: /\.jsx?$/,
exclude: [nodeModulesDir],
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: require.resolve('jquery'),
loader: 'expose-loader',
options: { exposes: ['$', 'jQuery', 'jquery'] },
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader'],
},
{
test: /\.(svg)(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset',
},
{
test: /\.(woff(2)?|eot|ttf)(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset',
},
{
test: /\.(jpg|png)?$/,
type: 'asset/resource',
generator: {
filename: 'i-[contenthash][ext]',
},
},
],
},
plugins: [
new BundleTracker({
path: __dirname,
filename: './assets/bundles/common-webpack-stats.json',
}),
new webpack.ProvidePlugin({
Tether: 'tether',
'window.Tether': 'tether',
Popper: ['popper.js', 'default'],
process: 'process/browser',
Alert: 'exports-loader?Alert!bootstrap/js/dist/alert',
Button: 'exports-loader?Button!bootstrap/js/dist/button',
Carousel: 'exports-loader?Carousel!bootstrap/js/dist/carousel',
Collapse: 'exports-loader?Collapse!bootstrap/js/dist/collapse',
Dropdown: 'exports-loader?Dropdown!bootstrap/js/dist/dropdown',
Modal: 'exports-loader?Modal!bootstrap/js/dist/modal',
Popover: 'exports-loader?Popover!bootstrap/js/dist/popover',
Scrollspy: 'exports-loader?Scrollspy!bootstrap/js/dist/scrollspy',
Tab: 'exports-loader?Tab!bootstrap/js/dist/tab',
Tooltip: 'exports-loader?Tooltip!bootstrap/js/dist/tooltip',
Util: 'exports-loader?Util!bootstrap/js/dist/util',
}),
],
},
{
context: __dirname,
entry: [
// defined in local or prod
],
output: {
// defined in local or prod
},
name: 'main',
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.(svg)(\?v=\d+\.\d+\.\d+)?$/,
type: 'asset',
},
{
test: /\.(jpg|png)?$/,
use: ['file-loader?name=i-[contenthash].[ext]'],
},
],
},
plugins: [
// defined in local or prod
],
resolve: {
modules: [
'node_modules',
'bower_components',
path.resolve(__dirname, 'assets/js/'),
],
extensions: ['.js', '.jsx'],
alias: {
'babel-runtime': '@babel/runtime',
'@vendors': path.resolve(__dirname, 'assets/vendors/'),
},
},
},
];