uhr/webpack.config.js

100 lines
3 KiB
JavaScript

const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
uhr: './src/index.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')
},
// devtool: 'inline-source-map',
mode: 'production',
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: [
{
loader: 'file-loader',
options: {
name: 'assets/[name].css'
}
},
{
loader: 'extract-loader',
options: {
publicPath: '../',
}
},
'css-loader',
{
loader: 'sass-loader',
options: {
outputStyle: 'compressed'
}
}
]
},
// {
// test: /\.s?css$/,
// use: [
// // fallback to style-loader in development
// process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
// 'css-loader',
// 'sass-loader'
// ]
// },
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: 'ts-loader'
}
]
},
plugins: [
new CleanWebpackPlugin({
dry: false,
cleanAfterEveryBuildPatterns: ['**/deleteme_*.del'],
dangerouslyAllowCleanPatternsOutsideProject: false
})
],
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: (chunkData) => chunkData.chunk.name === 'uhr' ? 'uhr.js' : 'deleteme_[name].del',
library: 'uhr',
path: path.resolve(__dirname, 'dist')
},
externals: {
jquery: 'jQuery',
'js-cookie': 'Cookies'
}
};