Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update light build targets to include Typescript extensions #2075

Merged
merged 1 commit into from Jan 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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