-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new Webpack config to create a modern and a legacy build
- Loading branch information
Showing
11 changed files
with
263 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
defaults |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const pkg = require('../../../package.json'); | ||
|
||
const commonBaseConfig = { | ||
devtool: 'source-map', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(js)$/, | ||
exclude: [/core-js/], | ||
use: [ | ||
{ | ||
loader: 'string-replace-loader', | ||
options: { | ||
search: '__VERSION__', | ||
replace: pkg.version, | ||
}, | ||
} | ||
], | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
fallback: { | ||
stream: require.resolve('stream-browserify'), | ||
}, | ||
}, | ||
} | ||
|
||
const prodEntries = { | ||
'dash.all': './index.js', | ||
'dash.mss': './src/mss/index.js', | ||
'dash.mediaplayer': './index_mediaplayerOnly.js', | ||
'dash.protection': './src/streaming/protection/Protection.js', | ||
'dash.reporting': './src/streaming/metrics/MetricsReporting.js', | ||
'dash.offline': './src/offline/index.js' | ||
} | ||
|
||
const devEntries = { | ||
'dash.all': './index.js', | ||
'dash.mss': './src/mss/index.js', | ||
'dash.offline': './src/offline/index.js' | ||
} | ||
|
||
module.exports = { commonBaseConfig, prodEntries, devEntries }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const EsLintWebpackPlugin = require('eslint-webpack-plugin'); | ||
const { prodEntries } = require('../common/webpack.common.base.cjs'); | ||
|
||
const plugins = [ | ||
new EsLintWebpackPlugin({ | ||
configType: 'flat', | ||
files: [ | ||
'src/**/*.js', | ||
'test/unit/mocks/*.js', | ||
'test/unit/test/**/*.js' | ||
] | ||
}) | ||
] | ||
|
||
const configCommonDebugProdUmd = { | ||
mode: 'development', | ||
entry: prodEntries, | ||
output: { | ||
filename: '[name].debug.js' | ||
} | ||
}; | ||
|
||
const configCommonMinProdUmd = { | ||
mode: 'production', | ||
entry: prodEntries, | ||
output: { | ||
filename: '[name].min.js' | ||
}, | ||
performance: { hints: false }, | ||
plugins | ||
}; | ||
|
||
const configCommonDebugProdEsm = { | ||
mode: 'development', | ||
entry: prodEntries, | ||
output: { | ||
filename: '[name].debug.esm.js' | ||
} | ||
}; | ||
|
||
const configCommonMinProdEsm = { | ||
mode: 'production', | ||
entry: prodEntries, | ||
output: { | ||
filename: '[name].min.esm.js' | ||
}, | ||
optimization: { | ||
usedExports: false, | ||
}, | ||
performance: { hints: false }, | ||
plugins | ||
}; | ||
|
||
module.exports = { configCommonDebugProdEsm, configCommonMinProdEsm, configCommonDebugProdUmd, configCommonMinProdUmd }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const path = require('path'); | ||
const { merge } = require('webpack-merge'); | ||
const { commonBaseConfig } = require('../common/webpack.common.base.cjs'); | ||
|
||
const legacyConfig = merge(commonBaseConfig, { | ||
target: ['web', 'es5'] | ||
}); | ||
|
||
legacyConfig.module.rules[0].use.push({ | ||
loader: 'babel-loader', | ||
options: { | ||
sourceType: 'unambiguous', | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
useBuiltIns: 'usage', | ||
targets: { | ||
ie: '11', | ||
}, | ||
corejs: '3.39.0', | ||
} | ||
], | ||
], | ||
plugins: [ | ||
'@babel/plugin-transform-runtime', | ||
'@babel/plugin-transform-parameters' | ||
], | ||
}, | ||
},) | ||
|
||
const umdConfig = merge(legacyConfig, { | ||
output: { | ||
path: path.resolve(__dirname, '../../../dist/legacy/umd'), | ||
publicPath: '/dist/legacy/umd/', | ||
library: 'dashjs', | ||
libraryTarget: 'umd', | ||
libraryExport: 'default' | ||
}, | ||
}); | ||
|
||
const esmConfig = merge(legacyConfig, { | ||
experiments: { | ||
outputModule: true | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, '../../../dist/legacy/esm'), | ||
publicPath: '/dist/legacy/esm/', | ||
library: { | ||
type: 'module', | ||
}, | ||
libraryExport: 'default', | ||
}, | ||
}); | ||
|
||
module.exports = { umdConfig, esmConfig }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { merge } = require('webpack-merge'); | ||
const { umdConfig, esmConfig } = require('./webpack.legacy.base.cjs'); | ||
const { | ||
configCommonDebugProdEsm, | ||
configCommonMinProdEsm, | ||
configCommonDebugProdUmd, | ||
configCommonMinProdUmd | ||
} = require('../common/webpack.common.prod.cjs'); | ||
|
||
const configLegacyDebugUmd = merge(umdConfig, configCommonDebugProdUmd); | ||
|
||
const configLegacyMinUmd = merge(umdConfig, configCommonMinProdUmd); | ||
|
||
const configLegacyDebugEsm = merge(esmConfig, configCommonDebugProdEsm); | ||
|
||
const configLegacyMinEsm = merge(esmConfig, configCommonMinProdEsm); | ||
|
||
module.exports = [configLegacyDebugUmd, configLegacyMinUmd, configLegacyDebugEsm, configLegacyMinEsm]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const path = require('path'); | ||
const { merge } = require('webpack-merge'); | ||
const { commonBaseConfig } = require('../common/webpack.common.base.cjs'); | ||
|
||
const modernConfig = merge(commonBaseConfig, { | ||
target: ['browserslist'] | ||
}); | ||
|
||
modernConfig.module.rules[0].use.push({ | ||
loader: 'babel-loader', | ||
options: { | ||
sourceType: 'unambiguous', | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
useBuiltIns: 'usage', | ||
corejs: '3.39.0', | ||
} | ||
], | ||
], | ||
plugins: [ | ||
'@babel/plugin-transform-runtime', | ||
'@babel/plugin-transform-parameters' | ||
], | ||
}, | ||
},) | ||
|
||
const umdConfig = merge(modernConfig, { | ||
output: { | ||
path: path.resolve(__dirname, '../../../dist/modern/umd'), | ||
publicPath: '/dist/modern/umd/', | ||
library: 'dashjs', | ||
libraryTarget: 'umd', | ||
libraryExport: 'default' | ||
}, | ||
}); | ||
|
||
const esmConfig = merge(modernConfig, { | ||
experiments: { | ||
outputModule: true | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, '../../../dist/modern/esm'), | ||
publicPath: '/dist/modern/esm/', | ||
library: { | ||
type: 'module', | ||
}, | ||
libraryExport: 'default', | ||
}, | ||
}); | ||
|
||
module.exports = { umdConfig, esmConfig }; |
Oops, something went wrong.