-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
69 lines (63 loc) · 2.04 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
const path = require('path');
// copy manifest.json to the path: 'public/build'
// this will allow for the authRequest to see the file at www.example.com/manifest.json
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HeadersPlugin = new CopyWebpackPlugin([{ from: 'public/', to: '.' }]);
const IonicDistPlugin = new CopyWebpackPlugin([ { from: 'node_modules/@ionic/core/dist', to: 'ionic' } ]);
const WorkboxPlugin = require('workbox-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
let PUBLIC_PATH = './';
process.argv.forEach(function (val) {
if (val.includes('target=web')) {
PUBLIC_PATH = '/';
}
});
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: './public/index.html',
filename: 'index.html',
inject: 'body',
base: PUBLIC_PATH
});
module.exports = {
entry: ['@babel/polyfill', './src/index.js'],
target: 'electron-main',
output: {
path: path.resolve('www'),
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js',
publicPath: PUBLIC_PATH
},
devServer: {
https: false,
historyApiFallback: {
disableDotRule: true
},
watchOptions: { aggregateTimeout: 300, poll: 1000 },
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",
},
port: 9876
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /\.(\/node_modules\/|\/build\/|\/electron\/|\/src\/server.js)(\?\S*)?$/
},
{ test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/,
loader: 'file-loader!url-loader',
},
{ test: /\.css$/, loader: 'style-loader!css-loader' }
]
},
plugins: [HtmlWebpackPluginConfig, IonicDistPlugin, HeadersPlugin,
new WorkboxPlugin.InjectManifest({
swSrc: './public/service-worker.js',
})
]
}