const path = require('path'); const CleanWebpackPlugin = require('clean-webpack-plugin'); module.exports = (env, argv) => ({ entry: { uhr: './src/index.ts', bundle: './src/bundle.ts', layout_de: require.resolve('./src/layout/layout-de.ts'), layout_de_ch: require.resolve('./src/layout/layout-de_ch.ts'), layout_de_ch_genau: require.resolve('./src/layout/layout-de_ch_genau.ts'), layout_dk: require.resolve('./src/layout/layout-dk.ts'), layout_en: require.resolve('./src/layout/layout-en.ts'), layout_es: require.resolve('./src/layout/layout-es.ts'), layout_fr: require.resolve('./src/layout/layout-fr.ts'), layout_it: require.resolve('./src/layout/layout-it.ts'), layout_nl: require.resolve('./src/layout/layout-nl.ts'), layout_pt: require.resolve('./src/layout/layout-pt.ts'), style_main: require.resolve('./resources/styles/uhr.scss'), style_black: require.resolve('./css/uhr-black.css'), style_blue: require.resolve('./css/uhr-blue.css'), style_green: require.resolve('./css/uhr-green.css'), style_pink: require.resolve('./css/uhr-pink.css'), style_red: require.resolve('./css/uhr-red.css'), style_white: require.resolve('./css/uhr-white.css'), style_yellow: require.resolve('./css/uhr-yellow.css') }, module: { rules: [ { enforce: 'pre', test: /\.tsx?$/, exclude: /node_modules/, use: 'eslint-loader' }, { test: /\.(png|svg|jpg|gif|woff)$/, use: [ { loader: 'file-loader', options: { name: 'assets/[name].[ext]' } } ] }, { test: /\.s?css$/, use: argv.mode !== 'production' ? [ 'style-loader', 'css-loader', 'sass-loader' ] : [ { loader: 'file-loader', options: { name: 'assets/[name].css' } }, { loader: 'extract-loader', options: { publicPath: '../', } }, 'css-loader', { loader: 'sass-loader', options: { outputStyle: 'compressed' } } ] }, { test: /\.tsx?$/, exclude: /node_modules/, use: 'ts-loader' } ] }, plugins: [ new CleanWebpackPlugin({ cleanAfterEveryBuildPatterns: ['deleteme/'], protectWebpackAssets: false }) ], resolve: { extensions: ['.tsx', '.ts', '.js'] }, output: { filename: (chunkData) => { if (chunkData.chunk.name === 'uhr') { return 'lib/uhr.js'; } if (chunkData.chunk.name === 'bundle') { return 'lib/uhr.bundle.js'; } if (chunkData.chunk.name.startsWith('layout')) { return 'lib/[name].js'; } return 'deleteme/[name]'; }, library: 'uhr', path: path.resolve(__dirname, 'dist') }, externals: { jquery: 'jQuery', 'js-cookie': 'Cookies' } });