-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·109 lines (99 loc) · 3.5 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*jshint esversion: 6 */
const path = require('path');
const webpack = require('webpack');
const htmlWebpackPlugin = require('html-webpack-plugin');
const miniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = (env = {}, argv = {}) => {
const cssFile = 'style-[hash:14].min.css';
const assetNames = 'assets/[name]-[hash:14].[ext]';
var config = {
entry: {
app: path.join(__dirname, "src/script", "app.ts")
},
output: {
path: path.resolve(__dirname, "www"),
filename: "[name]-[chunkhash:14].min.js",
chunkFilename: "[name]-[chunkhash:14].min.js"
},
target: "web",
devtool: false,
plugins: [
new htmlWebpackPlugin({
template: './src/index.html',
inject: true,
filename: 'index.html',
title: 'webpack-starter-template-svelte',
chunksSortMode: 'none'
}),
new miniCssExtractPlugin({
filename: cssFile
}),
new webpack.HashedModuleIdsPlugin()
],
performance: {
hints: "warning", //"warning", // error / false
},
module: {
rules: [
{
test: /\.ts(x?)$/,
use: [{ loader: 'ts-loader' }],
include: [
path.join(__dirname, "src")
]
},
{
test: /\.svelte$/,
exclude: /node_modules/,
use: {
loader: 'svelte-loader',
options: {
emitCss: true,
hotReload: true
}
},
},
{
test: /\.(css|sass)$/,
use: [
{
loader: miniCssExtractPlugin.loader
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: false
}
}, 'sass-loader?sourceMap=false'],
},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
use: 'url-loader?limit=1000&mimetype=application/font-woff&name=' + assetNames
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: 'url-loader?limit=1000&mimetype=application/octet-stream&name=' + assetNames
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
use: 'file-loader?name=' + assetNames
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: 'url-loader?limit=1000&mimetype=image/svg+xml&name=' + assetNames
},
{
test: /\.(png|jpg|gif)$/,
use: 'url-loader?limit=1000&name=' + assetNames
}
]
},
resolve: {
extensions: [".ts", ".js", ".sass", ".svelte"],
modules: [ path.resolve(__dirname, 'src'), "node_modules" ],
mainFields: ['svelte', 'browser', 'module', 'main']
}
};
return config;
};