forked from Semantic-Org/Semantic-UI-React
-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.webpack.js
67 lines (65 loc) · 1.63 KB
/
static.webpack.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
import path from 'path'
import webpack from 'webpack'
import config from './config'
export default (webpackConfig, { stage }) => ({
...webpackConfig,
devtool: config.compiler_devtool,
entry:
stage === 'prod'
? {
main: [config.paths.docsSrc('index.js'), config.paths.src('index.js')],
}
: webpackConfig.entry,
externals:
stage === 'node'
? webpackConfig.externals
: {
'anchor-js': 'AnchorJS',
'@babel/standalone': 'Babel',
faker: 'faker',
'prettier/standalone': 'prettier',
'prop-types': 'PropTypes',
react: 'React',
'react-dom': 'ReactDOM',
'react-dom/server': 'ReactDOMServer',
},
module: {
...webpackConfig.module,
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
},
],
},
plugins: [
new webpack.DefinePlugin({
__PATH_SEP__: JSON.stringify(path.sep),
}),
...webpackConfig.plugins,
],
resolve: {
alias: {
'semantic-ui-react': config.paths.src('index.js'),
},
// Heads up!
// We need this to prefer own node_modules instead of react-static's.
modules: [
config.paths.base(),
config.paths.base('node_modules'),
...webpackConfig.resolve.modules,
],
},
resolveLoader: {
// Heads up!
// We need this to resolve our own babel-loader for Babel 7. Can be safely removed when
// react-static will use Babel 7.
modules: [config.paths.base('node_modules'), 'node_modules'],
},
})