basic web page build restored
This commit is contained in:
parent
a2ade1cd68
commit
0cdfd136c5
@ -4,6 +4,7 @@ const FriendlyErrorsWebpackPlugin = require("friendly-errors-webpack-plugin");
|
||||
|
||||
module.exports = env => {
|
||||
return {
|
||||
mode: env || 'development',
|
||||
target: "node",
|
||||
node: {
|
||||
__dirname: false,
|
||||
|
2626
package-lock.json
generated
2626
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -145,19 +145,21 @@
|
||||
"babel-loader": "^8.0.0-beta.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
|
||||
"chai": "^4.1.2",
|
||||
"css-loader": "^0.28.7",
|
||||
"css-loader": "^0.28.11",
|
||||
"electron": "1.8.4",
|
||||
"electron-builder": "^19.56.2",
|
||||
"express": "^4.16.3",
|
||||
"friendly-errors-webpack-plugin": "^1.6.1",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"mocha": "^5.0.5",
|
||||
"socket.io": "^2.1.0",
|
||||
"source-map-support": "^0.5.0",
|
||||
"spectron": "^3.7.2",
|
||||
"style-loader": "^0.19.0",
|
||||
"style-loader": "^0.20.3",
|
||||
"sw-precache-webpack-plugin": "^0.11.5",
|
||||
"url-loader": "^0.6.2",
|
||||
"webpack": "^3.11.0",
|
||||
"webpack": "^4.5.0",
|
||||
"webpack-merge": "^4.1.2",
|
||||
"webpack-node-externals": "^1.6.0"
|
||||
"webpack-node-externals": "^1.7.2"
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,17 @@ import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
|
||||
import {Header} from './header'
|
||||
import Footer from './footer'
|
||||
|
||||
const { ipcRenderer, remote } = require('electron');
|
||||
window.currentWindow = remote.getCurrentWindow()
|
||||
|
||||
//var io = require("socket.io-client");
|
||||
//window.torrentSocket = io(document.location.protocol + '//' + document.location.hostname + (process.env.NODE_ENV === 'production' ? '/' : ':8095/'));
|
||||
if(typeof WEB !== 'undefined')
|
||||
{
|
||||
const io = require("socket.io-client");
|
||||
window.torrentSocket = io(document.location.protocol + '//' + document.location.hostname + (process.env.NODE_ENV === 'production' ? '/' : ':8095/'));
|
||||
}
|
||||
else
|
||||
{
|
||||
const { ipcRenderer, remote } = require('electron');
|
||||
window.currentWindow = remote.getCurrentWindow()
|
||||
|
||||
window.torrentSocket = {}
|
||||
window.torrentSocket.callbacks = {}
|
||||
window.torrentSocket.listeners = {}
|
||||
@ -53,12 +59,13 @@ window.currentWindow = remote.getCurrentWindow()
|
||||
delete window.torrentSocket.callbacks[id]
|
||||
});
|
||||
|
||||
|
||||
ipcRenderer.on('url', (event, url) => {
|
||||
console.log('url', url)
|
||||
router(url)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Needed for onTouchTap
|
||||
// http://stackoverflow.com/a/34015469/988941
|
||||
@ -132,7 +139,7 @@ class App extends Component {
|
||||
<MuiThemeProvider>
|
||||
<div>
|
||||
{
|
||||
!window.currentWindow.isModal()
|
||||
window.currentWindow && !window.currentWindow.isModal()
|
||||
&&
|
||||
<Header />
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ import TextField from 'material-ui/TextField'
|
||||
import Slider from 'material-ui/Slider'
|
||||
|
||||
import fs from 'fs'
|
||||
const {dialog} = require('electron').remote
|
||||
|
||||
export default class ConfigPage extends Page {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
@ -7,7 +7,6 @@ import TextField from 'material-ui/TextField'
|
||||
import Slider from 'material-ui/Slider'
|
||||
|
||||
import fs from 'fs'
|
||||
const {dialog} = require('electron').remote
|
||||
|
||||
export default class ConfigPage extends Page {
|
||||
constructor(props) {
|
||||
|
89
src/background/webpack.config.production.js
Normal file
89
src/background/webpack.config.production.js
Normal file
@ -0,0 +1,89 @@
|
||||
const webpack = require('webpack');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
|
||||
const glob = require('glob')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
//mode: 'production',
|
||||
entry: path.resolve("src/app/index.js"),
|
||||
output: {
|
||||
path: path.resolve('web'),
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: ["babel-loader"]
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ["style-loader", "css-loader"]
|
||||
},
|
||||
{
|
||||
test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/,
|
||||
use: ['url-loader']
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
inject: true,
|
||||
template: 'app/app.html',
|
||||
minify: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
removeRedundantAttributes: true,
|
||||
useShortDoctype: true,
|
||||
removeEmptyAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
keepClosingSlash: true,
|
||||
minifyJS: true,
|
||||
minifyCSS: true,
|
||||
minifyURLs: true,
|
||||
},
|
||||
}),
|
||||
new webpack.DefinePlugin({WEB: true}),
|
||||
// Generate a service worker script that will precache, and keep up to date,
|
||||
// the HTML & assets that are part of the Webpack build.
|
||||
new SWPrecacheWebpackPlugin({
|
||||
// By default, a cache-busting query parameter is appended to requests
|
||||
// used to populate the caches, to ensure the responses are fresh.
|
||||
// If a URL is already hashed by Webpack, then there is no concern
|
||||
// about it being stale, and the cache-busting can be skipped.
|
||||
dontCacheBustUrlsMatching: /\.\w{8}\./,
|
||||
filename: 'service-worker.js',
|
||||
logger(message) {
|
||||
if (message.indexOf('Total precache size is') === 0) {
|
||||
// This message occurs for every build and is a bit too noisy.
|
||||
return;
|
||||
}
|
||||
if (message.indexOf('Skipping static resource') === 0) {
|
||||
// This message obscures real errors so we ignore it.
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2612
|
||||
return;
|
||||
}
|
||||
console.log(message);
|
||||
},
|
||||
minify: true,
|
||||
// For unknown URLs, fallback to the index page
|
||||
navigateFallback: 'index.html',
|
||||
// Ignores URLs starting from /__ (useful for Firebase):
|
||||
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
|
||||
navigateFallbackWhitelist: [/^(?!\/__).*/],
|
||||
// Don't precache sourcemaps (they're large) and build asset manifest:
|
||||
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
|
||||
mergeStaticsConfig: true,
|
||||
staticFileGlobs: glob.sync('public/images/**/*.*').concat(glob.sync('public/sounds/**/*.*')),
|
||||
stripPrefix: 'public/',
|
||||
}),
|
||||
],
|
||||
node: {
|
||||
dgram: 'empty',
|
||||
fs: 'empty',
|
||||
net: 'empty',
|
||||
tls: 'empty',
|
||||
},
|
||||
};
|
12
src/background/webpack.js
Normal file
12
src/background/webpack.js
Normal file
@ -0,0 +1,12 @@
|
||||
const config = require('./webpack.config.production');
|
||||
const webpack = require('webpack');
|
||||
|
||||
let compiler = webpack(config);
|
||||
compiler.run((err, stats) => {
|
||||
if(err)
|
||||
throw new Error(err)
|
||||
|
||||
console.log('succesfully builder')
|
||||
if(stats.compilation.errors)
|
||||
console.error(stats.compilation.errors)
|
||||
})
|
Loading…
Reference in New Issue
Block a user