-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dev.js
executable file
·110 lines (101 loc) · 3.51 KB
/
webpack.config.dev.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
110
/*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 assetNames = 'assets/[name].[ext]';
var config = {
entry: {
app: path.join(__dirname, "src/script", "app.ts")
},
output: {
path: path.resolve(__dirname, "www"),
filename: "[name].js",
chunkFilename: "[name].js"
},
watch: true,
target: "web",
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, 'www'),
port: 8000,
hot: true,
open: true
},
plugins: [
new htmlWebpackPlugin({
template: './src/index.html',
inject: true,
filename: 'index.html',
title: 'webpack-starter-template-svelte',
chunksSortMode: 'none'
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.HashedModuleIdsPlugin(),
new webpack.WatchIgnorePlugin(['www', 'node_modules'])
],
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: 'style-loader'
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: true
}
}, '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: [".svelte", ".ts", ".js", ".sass"],
modules: [ path.resolve(__dirname, 'src'), "node_modules" ],
mainFields: ['svelte', 'browser', 'module', 'main']
}
};
return config;
};