Skip to content

Instantly share code, notes, and snippets.

@janis91
Created May 5, 2017 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janis91/919ffabd0829cdbcb6258e619cf5ccc0 to your computer and use it in GitHub Desktop.
Save janis91/919ffabd0829cdbcb6258e619cf5ccc0 to your computer and use it in GitHub Desktop.
Problem with externals
const webpack = require("webpack");
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
const path = require("path");
module.exports = function (env) {
let target = env.target;
let libraryName = ["OCA", "Ocr"];
let plugins = [];
let outputFile;
if (target === "production") {
plugins.push(new UglifyJsPlugin({ minimize: true }));
}
outputFile = "ocr[name].min.js";
const config = {
entry: {
app: __dirname + "/src/app.ts",
personal: __dirname + "/src/personal.ts"
},
output: {
path: __dirname + "/dist",
filename: outputFile,
library: libraryName,
libraryTarget: "umd",
umdNamedDefine: true
},
module: {
rules: [
{
test: /\.ts$/,
enforce: "pre",
loader: "tslint-loader",
options: {
tsConfigFile: "tsconfig.app.json",
}
},
{
test: /\.ts?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
configFileName: "tsconfig.app.json"
}
}
],
},
resolve: {
modules: [path.resolve("./src")],
extensions: [".ts"],
},
externals: {
underscore: { // UMD
commonjs: "underscore",
commonjs2: "underscore",
amd: "underscore",
root: "_"
}
},
plugins: plugins,
};
return config;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment