uhr/webpack.common.js

112 lines
3.8 KiB
JavaScript
Raw Permalink Normal View History

2019-05-05 02:44:01 +02:00
const path = require('path');
2019-05-08 00:01:54 +02:00
const CleanWebpackPlugin = require('clean-webpack-plugin');
2019-05-05 02:44:01 +02:00
module.exports = (env, argv) => ({
2019-05-08 00:01:54 +02:00
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'),
2019-05-08 00:01:54 +02:00
style_main: require.resolve('./resources/styles/uhr.scss'),
style_black: require.resolve('./css/uhr-black.scss'),
style_blue: require.resolve('./css/uhr-blue.scss'),
style_green: require.resolve('./css/uhr-green.scss'),
style_pink: require.resolve('./css/uhr-pink.scss'),
style_red: require.resolve('./css/uhr-red.scss'),
style_white: require.resolve('./css/uhr-white.scss'),
style_yellow: require.resolve('./css/uhr-yellow.scss')
2019-05-08 00:01:54 +02:00
},
2019-05-05 02:44:01 +02:00
module: {
rules: [
{
2019-05-05 12:18:46 +02:00
enforce: 'pre',
2019-05-05 02:44:01 +02:00
test: /\.tsx?$/,
2019-05-05 12:18:46 +02:00
exclude: /node_modules/,
use: 'eslint-loader'
2019-05-08 00:01:54 +02:00
},
{
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'
}
2019-05-08 00:01:54 +02:00
}
]
2019-05-08 00:01:54 +02:00
},
{
2019-05-05 12:18:46 +02:00
test: /\.tsx?$/,
exclude: /node_modules/,
use: 'ts-loader'
2019-05-05 02:44:01 +02:00
}
]
},
2019-05-08 00:01:54 +02:00
plugins: [
new CleanWebpackPlugin({
cleanAfterEveryBuildPatterns: ['deleteme/'],
protectWebpackAssets: false
2019-05-08 00:01:54 +02:00
})
],
2019-05-05 02:44:01 +02:00
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]';
},
2019-05-05 02:44:01 +02:00
path: path.resolve(__dirname, 'dist')
},
externals: {
jquery: 'jQuery',
'js-cookie': 'Cookies'
2019-05-05 02:44:01 +02:00
}
});