This repository has been archived by the owner on Oct 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
95 lines (90 loc) · 2.09 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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const sass = require('node-sass')
const postcss = require('postcss')
const mode = process.env.NODE_ENV || 'development'
const prod = mode === 'production'
// https://webpack.js.org/plugins/compression-webpack-plugin/
// https://webpack.js.org/guides/code-splitting/
const svelteLoaders = [require('./svelte-loader-config')(!prod)]
if (prod) {
svelteLoaders.unshift({
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {
useBuiltIns: 'entry',
corejs: 3
}]
],
sourceType: 'unambiguous'
}
})
}
module.exports = {
entry: {
bundle: [
"core-js",
"regenerator-runtime/runtime",
'./build/main.js'
]
},
resolve: {
extensions: ['.js', '.html', '.svelte', '.css', '.mjs']
},
output: {
path: path.join(__dirname, '/public'),
filename: '[name].js',
chunkFilename: '[name].[id].js'
},
module: {
rules: [
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader'
]
},
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
},
{
test: /\.svelte$/,
exclude: /node_modules/,
use: svelteLoaders
},
{
test: /\.(scss|sass)$/,
use: [
prod ? MiniCssExtractPlugin.loader : 'style-loader',
{ loader: 'css-loader', options: { importLoaders: 2 } },
'postcss-loader',
'sass-loader'
]
},
{
test: /\.css$/,
use: [
prod ? MiniCssExtractPlugin.loader : 'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader'
]
}
]
},
mode,
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new HtmlWebpackPlugin({
title: 'Svelte Typescript',
inject: 'body',
template: 'index.tmpl',
}),
],
devtool: 'source-map'
}