Skip to content

Commit ec409f3

Browse files
authored
Merge pull request #26 from oslabs-beta/staging
webpack changes
2 parents 9331184 + ad9adcd commit ec409f3

File tree

7 files changed

+187
-172
lines changed

7 files changed

+187
-172
lines changed

index-csp.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<!-- <link rel="stylesheet" href="./node_modules/chart.js/dist/Chart.min.css" /> -->
7-
<title>Document</title>
8-
</head>
9-
<body></body>
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<!-- <link rel="stylesheet" href="./node_modules/chart.js/dist/Chart.min.css" /> -->
8+
<title>Swell</title>
9+
</head>
10+
11+
<body></body>
12+
1013
</html>

package.json

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@
66
"repository": "https://github.com/open-source-labs/Swell",
77
"scripts": {
88
"test-jest": "jest",
9-
"test-mocha": "mocha",
10-
"build": "cross-env NODE_ENV=production webpack --mode=production --config ./webpack.production.js",
11-
"start": "electron --noDevServer .",
12-
"dev": "cross-env NODE_ENV=development webpack-dev-server --config ./webpack.development.js",
9+
"test-mocha": "webpack --mode=production --config ./webpack.production.js && mocha",
10+
"build": "webpack --mode=production --config ./webpack.production.js",
11+
"dev": "webpack-dev-server --mode=development --config ./webpack.development.js",
12+
"prod": "webpack --mode production --config ./webpack.production.js && electron --noDevServer .",
1313
"server": "nodemon test-server/server.js",
1414
"package-mac": "electron-builder build --x64 --mac",
1515
"package-all": "electron-builder build -mwl",
1616
"package-linux": "electron-builder build --linux",
1717
"gh-publish-mac": "electron-builder build --x64 --mac -p always",
18-
"gh-publish": "electron-builder build -mwl -p always",
19-
"postinstall": "npm rebuild grpc --runtime=electron --target=7.3.2"
18+
"gh-publish": "electron-builder build -mwl -p always"
2019
},
2120
"author": {
2221
"name": "Swell",
2322
"email": "swell@getswell.io",
2423
"url": "http://www.getswell.io"
2524
},
26-
"contributors": [
27-
{
25+
"contributors": [{
2826
"name": "Kyle Combs",
2927
"email": "combskyle@gmail.com",
3028
"url": "https://github.com/texpatnyc"
@@ -130,8 +128,7 @@
130128
"createDesktopShortcut": "always"
131129
},
132130
"dmg": {
133-
"contents": [
134-
{
131+
"contents": [{
135132
"x": 130,
136133
"y": 220
137134
},

webpack.build.config.js

Lines changed: 78 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,81 @@
1-
const webpack = require('webpack');
2-
const path = require('path');
3-
const HtmlWebpackPlugin = require('html-webpack-plugin');
4-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5-
const TerserPlugin = require('terser-webpack-plugin');
6-
const nodeExternals = require('webpack-node-externals');
1+
// Old config. Keeping just in case something breaks with the new webpack
72

3+
// const webpack = require('webpack');
4+
// const path = require('path');
5+
// const HtmlWebpackPlugin = require('html-webpack-plugin');
6+
// const MiniCssExtractPlugin = require('mini-css-extract-plugin');
7+
// const TerserPlugin = require('terser-webpack-plugin');
8+
// const nodeExternals = require('webpack-node-externals');
89

9-
// Any directories you will be adding code/files into,
10-
// need to be added to this array so webpack will pick them up
11-
const defaultInclude = path.resolve(__dirname, 'src');
10+
// // Any directories you will be adding code/files into,
11+
// // need to be added to this array so webpack will pick them up
12+
// const defaultInclude = path.resolve(__dirname, 'src');
1213

13-
module.exports = {
14-
module: {
15-
rules: [
16-
{
17-
test: /\.css$/,
18-
use: [
19-
MiniCssExtractPlugin.loader,
20-
'css-loader',
21-
],
22-
include: defaultInclude,
23-
},
24-
{
25-
test: /\.scss$/,
26-
use: [
27-
'style-loader',
28-
'css-loader',
29-
'sass-loader',
30-
],
31-
include: defaultInclude,
32-
},
33-
{
34-
test: /\.jsx?$/,
35-
use: [{ loader: 'babel-loader' }],
36-
include: defaultInclude,
37-
},
38-
{
39-
test: /\.(jpe?g|png|gif)$/,
40-
use: [{ loader: 'file-loader?name=img/[name]__[hash:base64:5].[ext]' }],
41-
include: defaultInclude,
42-
},
43-
{
44-
test: /\.(eot|svg|ttf|woff|woff2|mp3)$/,
45-
use: [{ loader: 'file-loader?name=font/[name]__[hash:base64:5].[ext]' }],
46-
include: defaultInclude,
47-
},
48-
],
49-
},
50-
target: 'electron-renderer',
51-
optimization: {
52-
minimize: true,
53-
minimizer: [new TerserPlugin({
54-
terserOptions: {
55-
compress: {
56-
57-
},
58-
},
59-
})],
60-
},
61-
externals: [nodeExternals()],
62-
plugins: [
63-
new HtmlWebpackPlugin(),
64-
new MiniCssExtractPlugin({
65-
// Options similar to the same options in webpackOptions.output
66-
// both options are optional
67-
filename: 'bundle.css',
68-
chunkFilename: '[id].css',
69-
}),
70-
new webpack.DefinePlugin({
71-
'process.env.NODE_ENV': JSON.stringify('production'),
72-
}),
73-
],
74-
stats: {
75-
colors: true,
76-
children: false,
77-
chunks: false,
78-
modules: false,
79-
},
80-
};
14+
// module.exports = {
15+
// module: {
16+
// rules: [
17+
// {
18+
// test: /\.css$/,
19+
// use: [
20+
// MiniCssExtractPlugin.loader,
21+
// 'css-loader',
22+
// ],
23+
// include: defaultInclude,
24+
// },
25+
// {
26+
// test: /\.scss$/,
27+
// use: [
28+
// 'style-loader',
29+
// 'css-loader',
30+
// 'sass-loader',
31+
// ],
32+
// include: defaultInclude,
33+
// },
34+
// {
35+
// test: /\.jsx?$/,
36+
// use: [{ loader: 'babel-loader' }],
37+
// include: defaultInclude,
38+
// },
39+
// {
40+
// test: /\.(jpe?g|png|gif)$/,
41+
// use: [{ loader: 'file-loader?name=img/[name]__[hash:base64:5].[ext]' }],
42+
// include: defaultInclude,
43+
// },
44+
// {
45+
// test: /\.(eot|svg|ttf|woff|woff2|mp3)$/,
46+
// use: [{ loader: 'file-loader?name=font/[name]__[hash:base64:5].[ext]' }],
47+
// include: defaultInclude,
48+
// },
49+
// ],
50+
// },
51+
// target: 'electron-renderer',
52+
// optimization: {
53+
// minimize: true,
54+
// minimizer: [new TerserPlugin({
55+
// terserOptions: {
56+
// compress: {
57+
58+
// },
59+
// },
60+
// })],
61+
// },
62+
// externals: [nodeExternals()],
63+
// plugins: [
64+
// new HtmlWebpackPlugin(),
65+
// new MiniCssExtractPlugin({
66+
// // Options similar to the same options in webpackOptions.output
67+
// // both options are optional
68+
// filename: 'bundle.css',
69+
// chunkFilename: '[id].css',
70+
// }),
71+
// new webpack.DefinePlugin({
72+
// 'process.env.NODE_ENV': JSON.stringify('production'),
73+
// }),
74+
// ],
75+
// stats: {
76+
// colors: true,
77+
// children: false,
78+
// chunks: false,
79+
// modules: false,
80+
// },
81+
// };

webpack.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
output: {
1212
path: path.resolve(__dirname, "dist"),
1313
filename: "bundle.js",
14-
publicPath: "./",
14+
publicPath: "/",
1515
},
1616
module: {
1717
rules: [
@@ -53,7 +53,8 @@ module.exports = {
5353
plugins: [
5454
new MiniCssExtractPlugin({}),
5555
new HtmlWebpackPlugin({
56-
template: path.resolve(__dirname, "index-csp.html"),
56+
// if using template, add <title>Swell</title> and delete line 59.
57+
// template: path.resolve(__dirname, "index-csp.html"),
5758
filename: "index.html",
5859
title: "Swell",
5960
cspPlugin: {

webpack.dev.config.js

Lines changed: 83 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,85 @@
1-
const webpack = require('webpack');
2-
const path = require('path');
3-
const HtmlWebpackPlugin = require('html-webpack-plugin');
4-
const {
5-
spawn
6-
} = require('child_process');
7-
const nodeExternals = require('webpack-node-externals');
1+
// Old config. Keeping just in case something breaks with the new webpack
82

9-
// Any directories you will be adding code/files into,
10-
// need to be added to this array so webpack will pick them up
11-
const defaultInclude = path.resolve(__dirname, 'src');
3+
// const webpack = require("webpack");
4+
// const path = require("path");
5+
// const HtmlWebpackPlugin = require("html-webpack-plugin");
6+
// const { spawn } = require("child_process");
7+
// const nodeExternals = require("webpack-node-externals");
128

13-
module.exports = {
14-
module: {
15-
rules: [{
16-
test: /\.scss$/,
17-
use: ['style-loader', 'css-loader', 'sass-loader'],
18-
},
19-
{
20-
test: /\.css$/,
21-
use: [{
22-
loader: 'style-loader'
23-
}, {
24-
loader: 'css-loader'
25-
}],
26-
},
27-
{
28-
test: /\.(js|jsx)$/,
29-
exclude: /node_modules/,
30-
use: [{
31-
loader: 'babel-loader'
32-
}],
33-
},
34-
{
35-
test: /\.(jpe?g|png|gif)$/,
36-
use: [{
37-
loader: 'file-loader?name=img/[name]__[hash:base64:5].[ext]'
38-
}],
39-
},
40-
{
41-
test: /\.(eot|svg|ttf|woff|woff2|mp3)$/,
42-
use: [{
43-
loader: 'file-loader?name=font/[name]__[hash:base64:5].[ext]'
44-
}]
45-
}
46-
]
47-
},
48-
target: 'electron-main',
49-
externals: [nodeExternals()],
50-
plugins: [
51-
new HtmlWebpackPlugin(),
52-
new webpack.DefinePlugin({
53-
'process.env.NODE_ENV': JSON.stringify('development'),
54-
}),
55-
],
56-
devtool: 'cheap-source-map',
57-
devServer: {
58-
contentBase: path.resolve(__dirname, 'dist'),
59-
stats: {
60-
colors: true,
61-
chunks: false,
62-
children: false,
63-
},
64-
before() {
65-
console.log('firing the before line!');
66-
spawn('electron', ['.'], {
67-
shell: true,
68-
env: process.env,
69-
stdio: 'inherit',
70-
})
71-
.on('close', code => process.exit(0))
72-
.on('error', spawnError => console.error(spawnError));
73-
},
74-
}
75-
};
9+
// // Any directories you will be adding code/files into,
10+
// // need to be added to this array so webpack will pick them up
11+
// const defaultInclude = path.resolve(__dirname, "src");
12+
13+
// module.exports = {
14+
// module: {
15+
// rules: [
16+
// {
17+
// test: /\.scss$/,
18+
// use: ["style-loader", "css-loader", "sass-loader"],
19+
// },
20+
// {
21+
// test: /\.css$/,
22+
// use: [
23+
// {
24+
// loader: "style-loader",
25+
// },
26+
// {
27+
// loader: "css-loader",
28+
// },
29+
// ],
30+
// },
31+
// {
32+
// test: /\.(js|jsx)$/,
33+
// exclude: /node_modules/,
34+
// use: [
35+
// {
36+
// loader: "babel-loader",
37+
// },
38+
// ],
39+
// },
40+
// {
41+
// test: /\.(jpe?g|png|gif)$/,
42+
// use: [
43+
// {
44+
// loader: "file-loader?name=img/[name]__[hash:base64:5].[ext]",
45+
// },
46+
// ],
47+
// },
48+
// {
49+
// test: /\.(eot|svg|ttf|woff|woff2|mp3)$/,
50+
// use: [
51+
// {
52+
// loader: "file-loader?name=font/[name]__[hash:base64:5].[ext]",
53+
// },
54+
// ],
55+
// },
56+
// ],
57+
// },
58+
// target: "electron-main",
59+
// externals: [nodeExternals()],
60+
// plugins: [
61+
// new HtmlWebpackPlugin(),
62+
// // new webpack.DefinePlugin({
63+
// // 'process.env.NODE_ENV': JSON.stringify('development'),
64+
// // }),
65+
// ],
66+
// devtool: "cheap-source-map",
67+
// devServer: {
68+
// contentBase: path.resolve(__dirname, "dist"),
69+
// stats: {
70+
// colors: true,
71+
// chunks: false,
72+
// children: false,
73+
// },
74+
// before() {
75+
// console.log("firing the before line!");
76+
// spawn("electron", ["."], {
77+
// shell: true,
78+
// env: process.env,
79+
// stdio: "inherit",
80+
// })
81+
// .on("close", (code) => process.exit(0))
82+
// .on("error", (spawnError) => console.error(spawnError));
83+
// },
84+
// },
85+
// };

0 commit comments

Comments
 (0)