This repository has been archived by the owner on Sep 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
56 lines (52 loc) · 2 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
const cssLoader = 'css-loader';
const postcssLoader = {
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [ require('tailwindcss')('tailwind.config.js'), 'autoprefixer', ]
}
}
};
module.exports = function(env, { analyze }) {
const production = env.production || process.env.NODE_ENV === 'production';
return {
target: 'web',
mode: production ? 'production' : 'development',
devtool: production ? undefined : 'eval-cheap-source-map',
entry: {
entry: './src/main.ts'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: production ? '[name].[contenthash].bundle.js' : '[name].bundle.js'
},
resolve: {
extensions: ['.ts', '.js'],
modules: [path.resolve(__dirname, 'src'), 'node_modules']
},
devServer: {
historyApiFallback: true,
open: !process.env.CI,
port: 9000
},
module: {
rules: [
{ test: /\.(png|gif|jpg|cur)$/i, loader: 'url-loader', options: { limit: 8192 } },
{ test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff2' } },
{ test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff' } },
{ test: /\.(ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'file-loader' },
{ test: /\.css$/i, use: [ 'style-loader', cssLoader, postcssLoader ] },
{ test: /\.ts$/i, use: ['ts-loader', '@aurelia/webpack-loader'], exclude: /node_modules/ },
{ test: /[/\\]src[/\\].+\.html$/i, use: '@aurelia/webpack-loader', exclude: /node_modules/ }
]
},
plugins: [
new HtmlWebpackPlugin({ template: 'index.html' }),
analyze && new BundleAnalyzerPlugin()
].filter(p => p)
}
}