Skip to content

Commit

Permalink
Merge pull request #2075 from itsjamie/update-webpack-merge
Browse files Browse the repository at this point in the history
Update light build targets to include Typescript extensions
  • Loading branch information
michaelcunningham19 committed Jan 12, 2019
2 parents 259c6c0 + 253c861 commit 7021254
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -86,6 +86,7 @@
"webpack-bundle-analyzer": "^2.9.1",
"webpack-cli": "^3.0.2",
"webpack-dev-server": "^3.1.4",
"webpack-merge": "^4.2.1",
"webworkify-webpack": "^2.1.2"
}
}
26 changes: 13 additions & 13 deletions webpack.config.js
@@ -1,14 +1,13 @@
const pkgJson = require('./package.json');
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

const getGitVersion = require('git-tag-version');
const getGitCommitInfo = require('git-commit-info');

const clone = (...args) => Object.assign({}, ...args);

/* Allow to customise builds through env-vars */
const env = process.env;

Expand All @@ -22,19 +21,22 @@ const baseConfig = {
entry: './src/hls',
resolve: {
// Add `.ts` as a resolvable extension.
extensions: [".ts", ".js"]
extensions: ['.ts', '.js']
},
module: {
strictExportPresence: true,
rules: [
// all files with a `.ts` extension will be handled by `ts-loader`
{ test: /\.ts?$/, loader: "ts-loader" },
{ test: /\.js?$/, exclude: [/node_modules/], loader: "ts-loader" },
{
test: /\.(ts|js)$/,
loader: 'ts-loader',
exclude: /node_modules/
}
]
}
};

const demoConfig = clone(baseConfig, {
const demoConfig = merge(baseConfig, {
name: 'demo',
mode: 'development',
entry: './demo/main',
Expand All @@ -47,7 +49,7 @@ const demoConfig = clone(baseConfig, {
library: 'HlsDemo',
libraryTarget: 'umd',
libraryExport: 'default',
globalObject: 'this' // https://github.com/webpack/webpack/issues/6642#issuecomment-370222543
globalObject: 'this' // https://github.com/webpack/webpack/issues/6642#issuecomment-370222543
},
optimization: {
minimize: false
Expand All @@ -56,7 +58,7 @@ const demoConfig = clone(baseConfig, {
devtool: 'source-map'
});

function getPluginsForConfig(type, minify = false) {
function getPluginsForConfig (type, minify = false) {
// common plugins.

const defineConstants = getConstantsForConfig(type);
Expand Down Expand Up @@ -86,7 +88,6 @@ function getPluginsForConfig(type, minify = false) {
}

function getConstantsForConfig (type) {

const gitCommitInfo = getGitCommitInfo();
const suffix = gitCommitInfo.shortCommit ? ('-' + gitCommitInfo.shortCommit) : '';

Expand All @@ -109,7 +110,7 @@ function getAliasesForLightDist () {
}

if (!addSubtitleSupport) {
aliases = clone(aliases, {
aliases = Object.assign(aliases, {
'./utils/cues': './empty.js',
'./controller/timeline-controller': './empty.js',
'./controller/subtitle-track-controller': './empty.js',
Expand All @@ -118,7 +119,7 @@ function getAliasesForLightDist () {
}

if (!addAltAudioSupport) {
aliases = clone(aliases, {
aliases = Object.assign(aliases, {
'./controller/audio-track-controller': './empty.js',
'./controller/audio-stream-controller': './empty.js'
});
Expand Down Expand Up @@ -206,13 +207,12 @@ const multiConfig = [
},
devtool: 'source-map'
}
].map(config => clone(baseConfig, config));
].map(config => merge(baseConfig, config));

multiConfig.push(demoConfig);

// webpack matches the --env arguments to a string; for example, --env.debug.min translates to { debug: true, min: true }
module.exports = (envArgs) => {

let configs;

if (!envArgs) {
Expand Down

0 comments on commit 7021254

Please sign in to comment.