forked from bbc/react-transcript-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
108 lines (106 loc) · 3.51 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// based on https://itnext.io/how-to-package-your-react-component-for-distribution-via-npm-d32d4bf71b4f
// and http://jasonwatmore.com/post/2018/04/14/react-npm-how-to-publish-a-react-component-to-npm
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const isDevelopment = process.env.NODE_ENV !== 'production';
module.exports = {
mode: 'production',
devtool: 'source-map',
entry: {
index: './packages/index.js',
TranscriptEditor: './packages/components/transcript-editor/index.js',
TimedTextEditor: './packages/components/timed-text-editor/index.js',
MediaPlayer: './packages/components/media-player/index.js',
ProgressBar: './packages/components/media-player/src/ProgressBar.js',
PlaybackRate: './packages/components/media-player/src/PlaybackRate.js',
PlayerControls: './packages/components/media-player/src/PlayerControls/index.js',
Select: './packages/components/media-player/src/Select.js',
VideoPlayer: './packages/components/video-player/index.js',
Settings: './packages/components/settings/index.js',
KeyboardShortcuts: './packages/components/keyboard-shortcuts/index.js',
timecodeConverter: './packages/util/timecode-converter/index.js',
exportAdapter: './packages/export-adapters/index.js',
sttJsonAdapter: './packages/stt-adapters/index.js',
groupWordsInParagraphsBySpeakersDPE: './packages/stt-adapters/digital-paper-edit/group-words-by-speakers.js'
},
output: {
path: path.resolve('dist'),
filename: '[name].js',
libraryTarget: 'commonjs2'
},
optimization: {
minimize: true
},
plugins: [
new MiniCssExtractPlugin({
filename: isDevelopment ? '[name].css' : '[name].[hash].css',
chunkFilename: isDevelopment ? '[id].css' : '[id].[hash].css'
})
],
module: {
rules: [
{
test: /\.module.(sa|sc|c)ss$/,
use: [
isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: { modules: true, sourceMap: isDevelopment }
},
{
loader: 'sass-loader',
options: { sourceMap: isDevelopment }
}
]
},
{
test: /\.s(a|c)ss$/,
exclude: /\.module.(s(a|c)ss)$/,
use: [
isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: { sourceMap: isDevelopment }
},
{
loader: 'sass-loader',
options: { sourceMap: isDevelopment }
}
]
},
{
test: /\.(js|jsx)$/,
include: path.resolve(__dirname, 'packages'),
// TODO: because it uses entry point to determine graph of dependencies, might not be needed to exclude test ans sample files?
exclude: /(node_modules|bower_components|build|dist|demo|.storybook)/,
use: {
loader: 'babel-loader',
options: {
presets: [ '@babel/preset-env', '@babel/preset-react' ]
}
}
}
]
},
resolve: {
alias: {
'react': path.resolve(__dirname, './node_modules/react'),
'react-dom': path.resolve(__dirname, './node_modules/react-dom')
}
},
externals: {
// Don't bundle react or react-dom
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'React',
root: 'React'
},
'react-dom': {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'ReactDOM',
root: 'ReactDOM'
}
}
};