import { styleLoaders as taStyles, tsLoader } from "@lonelyplanet/travel-agent/dist/webpack/loaders"; import * as ExtractTextPlugin from "extract-text-webpack-plugin"; import * as path from "path"; import * as UglifyJSPlugin from "uglifyjs-webpack-plugin"; import * as w from "webpack"; import * as pkg from "./package.json"; const mode = "production"; const styleLoaders = { ...taStyles }; styleLoaders.css.options.localIdentName = "lp-global-[local]"; styleLoaders.css.options.context = path.resolve(__dirname, "src"); export const extractCssLoader = { test: /\.css$/, include: /src/, loader: ExtractTextPlugin.extract({ fallback: "style-loader", use: [styleLoaders.css, styleLoaders.postcss], }), }; const tsLoaderCopy = { ...tsLoader }; tsLoaderCopy.use[0].options = { configFile: path.resolve("./tsconfig-es.json") }; const rules = [ tsLoaderCopy, extractCssLoader, ]; const config: w.Configuration = { mode, entry: { core: "./src/client.tsx", }, output: { chunkFilename: "[name]-chunk.js", filename: "[name].min.js", path: path.resolve(__dirname, "lib"), publicPath: `https://assets.staticlp.com/dotcom-core/${pkg.version}/`, libraryTarget: "umd", jsonpFunction: "webpackJsonpDotcomCore", }, module: { rules, }, resolve: { extensions: [".js", ".jsx", ".ts", ".tsx"], }, plugins: [ new ExtractTextPlugin({ filename: "[name].css", disable: false, allChunks: true, }), new UglifyJSPlugin({ sourceMap: true, }), ], devtool: "source-map", }; export default config;