forked from MailOnline/mol-video-ad-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
94 lines (90 loc) · 2.33 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
/* eslint-disable import/unambiguous, import/no-commonjs, sort-keys */
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const {name: pkgName} = require('./package.json');
// eslint-disable-next-line no-process-env
const devMode = process.env.NODE_ENV !== 'production';
const alias = {};
if (devMode) {
alias['@mailonline/video-ad-sdk'] = path.resolve(__dirname, 'src/index.js');
} else {
alias['@mailonline/video-ad-sdk'] = path.resolve(__dirname, 'dist/main.esm.js');
}
module.exports = {
entry: {demo: './demo/index'},
devtool: 'source-map',
devServer: {
publicPath: '/',
contentBase: [
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'ghPage')
],
compress: true,
https: true,
port: 9000,
headers: {
'Access-Control-Allow-Origin': '*'
}
},
externals: {
'video.js': {
commonjs: 'video.js',
commonjs2: 'video.js',
root: 'videojs'
}
},
module: {
rules: [
{
exclude: devMode ? /node_modules\/(?!@mailonline\/).*/ : /node_modules\/.*/,
loader: 'babel-loader',
test: /\.js$/
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}
]
},
optimization: {
minimize: !devMode,
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true
}),
new OptimizeCSSAssetsPlugin({})
]
},
output: {
libraryTarget: 'umd',
devtoolFallbackModuleFilenameTemplate: `webpack:///${pkgName}/[resource-path]?[hash]`,
devtoolModuleFilenameTemplate: `webpack:///${pkgName}/[resource-path]`,
publicPath: devMode ? 'http://localhost:9000/' : '../',
path: path.resolve(__dirname, 'pages/demo/')
},
plugins: [
new HtmlWebpackPlugin({
title: 'MOL Video Ad SDK Suite Inspector',
template: './demo/index.html',
filename: 'index.html',
minify: false,
chunks: []
}),
new MiniCssExtractPlugin({
filename: '[name].css'
})
],
resolve: {
extensions: ['.js'],
modules: ['node_modules'],
alias
}
};