-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·81 lines (72 loc) · 2.78 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 path = require('path');
const fs = require('fs');
const srcPath = path.join(process.env.PROJECT_CWD, './develop/assets/js');
const distPath = path.join(process.env.PROJECT_CWD, './web-ui/assets/js');
let babelConfig;
try {
fs.accessSync(`${ process.env.PROJECT_CWD }/babel.config.js`, fs.constants.R_OK | fs.constants.W_OK);
babelConfig = `${process.env.PROJECT_CWD}/babel.config.js`
console.error('use babel project config!');
} catch (err) {
console.error('use babel package config!');
babelConfig = `./babel.config.js`
}
/**
* Resources for lazy loading:
* https://medium.com/front-end-hacking/webpack-and-dynamic-imports-doing-it-right-72549ff49234
* https://webpack.js.org/guides/public-path/
*/
module.exports = {
context: srcPath,
entry: {
app: './app.js'
},
output: {
path: distPath,
chunkFilename: 'vhug-[name].bundle.js',
filename: 'vhug-[name].bundle.js'
},
resolve: {
alias: {
base: path.resolve(process.env.PROJECT_CWD),
dev: path.resolve(process.env.PROJECT_CWD, 'develop/'),
glb: path.resolve(process.env.PROJECT_CWD, 'develop/00-globals/'),
functions: path.resolve(process.env.PROJECT_CWD, 'develop/00-globals/04-glb-functions/'),
objects: path.resolve(process.env.PROJECT_CWD, 'develop/01-objects/'),
components: path.resolve(process.env.PROJECT_CWD, 'develop/02-components/'),
modules: path.resolve(process.env.PROJECT_CWD, 'develop/03-modules'),
styleguide: path.resolve(process.env.PROJECT_CWD, 'develop/05-styleguide'),
}
},
module: {
rules: [
{
test: /^(?!.*\.config\.js$).*\.js$/,
exclude: /(node_modules)/,
/* if you decide to bundle GSAP and not use the umd verion you would need to
* use include instead of exclude to properly babelify GSAP or it fails on older browsers.
*/
// include: [
// srcPath,
// /(node_modules\/gsap)/
// ],
use: {
// https://github.com/babel/babel-loader
loader: 'babel-loader',
options: {
presets: ['@babel/env'],
plugins: ['@babel/plugin-syntax-dynamic-import'],
configFile: babelConfig
}
}
}
]
},
/** Externals
* In case you want to include external plugins and they need dependencies that are part of the bundle.
* Useful for some GSAP plugins like DrawSVGPlugin which are not yet optimized for Webpack.
**/
// externals: {
// 'TweenLite': 'TweenLite'
// },
};