forked from folio-org/stripes-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.base.js
77 lines (75 loc) · 2.4 KB
/
webpack.config.base.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
// Common Webpack configuration for building Stripes
const fs = require('fs');
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const { generateStripesAlias } = require('./webpack/module-paths');
const babelLoaderRule = require('./webpack/babel-loader-rule');
const typescriptLoaderRule = require('./webpack/typescript-loader-rule');
// React doesn't like being included multiple times as can happen when using
// yarn link. Here we find a more specific path to it by first looking in
// stripes-core (__dirname) before falling back to the platform or simply react
const specificReact = generateStripesAlias('react');
module.exports = {
entry: [
'@folio/stripes-components/lib/global.css',
path.join(__dirname, 'src', 'index'),
],
resolve: {
alias: {
'react': specificReact,
'react-dom': '@hot-loader/react-dom',
},
extensions: ['.js', '.json', '.tsx'],
},
plugins: [
new HtmlWebpackPlugin({
template: fs.existsSync('index.html') ? 'index.html' : `${__dirname}/index.html`,
}),
new webpack.EnvironmentPlugin(['NODE_ENV']),
// https://github.com/lodash/lodash-webpack-plugin#feature-sets
// Replace lodash feature sets of modules with noop.
// Feature sets that are truly not needed can be disabled here (listed largest to smallest):
new LodashModuleReplacementPlugin({
'shorthands': true,
'cloning': true,
'currying': true,
'caching': true,
'collections': true,
'exotics': true,
'guards': true,
'metadata': true, // (requires currying)
'deburring': true,
'unicode': true,
'chaining': true,
'memoizing': true,
'coercions': true,
'flattening': true,
'paths': true,
'placeholders': true // (requires currying)
})
],
module: {
rules: [
babelLoaderRule,
typescriptLoaderRule,
{
test: /\.(jpg|jpeg|gif|png|ico)$/,
loader: 'file-loader?name=img/[path][name].[hash].[ext]',
},
{
test: /\.(mp3|m4a)$/,
loader: 'file-loader?name=sound/[name].[hash].[ext]',
},
{
test: /\.(woff2?)$/,
loader: 'file-loader?name=fonts/[name].[hash].[ext]',
},
{
test: /\.handlebars$/,
loader: 'handlebars-loader',
},
],
},
};