generated from nienow/sn-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
105 lines (103 loc) · 2.18 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
const ZipPlugin = require('zip-webpack-plugin');
const PACKAGE = require('./package.json');
const version = PACKAGE.version;
module.exports = (env, argv) => ({
mode: 'production',
devtool: 'source-map',
entry: {
main: 'index.tsx',
demo: 'demo/demo.tsx'
},
output: {
filename: "[name].[contenthash].js",
clean: true
},
optimization: {
splitChunks: {
chunks: 'all',
},
},
externals: {
'filesafe-js': {}
},
module: {
rules: [
{
test: /\.(ts|tsx|js|jsx|mjs|cjs)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.css$/i,
use: [
"style-loader",
"css-loader",
],
},
{
test: /\.scss$/i,
use: [
"style-loader",
"css-loader",
"sass-loader"
],
},
{
test: /\.(jpg|png|gif|jpeg)$/,
loader: 'url-loader',
}
]
},
resolve: {
modules: [
'node_modules',
'src'
],
extensions: ['.tsx', '.ts', '.js'],
alias: {
react: "preact/compat",
'react-dom': "preact/compat",
"react/jsx-runtime": "preact/jsx-runtime",
"react-jsx-runtime": "preact/jsx-runtime"
}
},
devServer: {
hot: false,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
},
},
plugins: [
new HtmlWebpackPlugin({
filename: "index.html",
template: "./src/index.html",
chunks: ["main"]
}),
new HtmlWebpackPlugin({
filename: "demo.html",
template: "./src/index.html",
chunks: ["demo"]
}),
new CopyPlugin({
patterns: [
{
from: 'public',
transform(content) {
return content
.toString()
.replace('$VERSION$', version);
}
}
]
}),
new ZipPlugin({
filename: `latest.zip`
})
],
});