web -> desktop

This commit is contained in:
Alexey Kasyanchuk
2018-01-31 19:02:28 +03:00
parent 0e4888ab76
commit d8afce8964
95 changed files with 10679 additions and 1893 deletions

20
build/start.js Normal file
View File

@ -0,0 +1,20 @@
const childProcess = require("child_process");
const electron = require("electron");
const webpack = require("webpack");
const config = require("./webpack.app.config");
const env = "development";
const compiler = webpack(config(env));
let electronStarted = false;
const watching = compiler.watch({}, (err, stats) => {
if (!err && !stats.hasErrors() && !electronStarted) {
electronStarted = true;
childProcess
.spawn(electron, ["."], { stdio: "inherit" })
.on("close", () => {
watching.close();
});
}
});

View File

@ -0,0 +1,16 @@
const path = require("path");
const merge = require("webpack-merge");
const base = require("./webpack.base.config");
module.exports = env => {
return merge(base(env), {
entry: {
background: "./src/background/background.js",
app: "./src/app/index.js"
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "../app")
}
});
};

View File

@ -0,0 +1,40 @@
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const FriendlyErrorsWebpackPlugin = require("friendly-errors-webpack-plugin");
module.exports = env => {
return {
target: "node",
node: {
__dirname: false,
__filename: false
},
externals: [nodeExternals()],
resolve: {
alias: {
env: path.resolve(__dirname, `../config/env_${env}.json`)
}
},
devtool: "source-map",
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 FriendlyErrorsWebpackPlugin({ clearConsole: env === "development" })
]
};
};

View File

@ -0,0 +1,29 @@
const merge = require("webpack-merge");
const jetpack = require("fs-jetpack");
const base = require("./webpack.base.config");
// Test files are scattered through the whole project. Here we're searching
// for them and generating entry file for webpack.
const e2eDir = jetpack.cwd("e2e");
const tempDir = jetpack.cwd("temp");
const entryFilePath = tempDir.path("e2e_entry.js");
const entryFileContent = e2eDir
.find({ matching: "*.e2e.js" })
.reduce((fileContent, path) => {
const normalizedPath = path.replace(/\\/g, "/");
return `${fileContent}import "../e2e/${normalizedPath}";\n`;
}, "");
jetpack.write(entryFilePath, entryFileContent);
module.exports = env => {
return merge(base(env), {
entry: entryFilePath,
output: {
filename: "e2e.js",
path: tempDir.path()
}
});
};

View File

@ -0,0 +1,29 @@
const merge = require("webpack-merge");
const jetpack = require("fs-jetpack");
const base = require("./webpack.base.config");
// Test files are scattered through the whole project. Here we're searching
// for them and generating entry file for webpack.
const srcDir = jetpack.cwd("src");
const tempDir = jetpack.cwd("temp");
const entryFilePath = tempDir.path("specs_entry.js");
const entryFileContent = srcDir
.find({ matching: "*.spec.js" })
.reduce((fileContent, path) => {
const normalizedPath = path.replace(/\\/g, "/");
return `${fileContent}import "../src/${normalizedPath}";\n`;
}, "");
jetpack.write(entryFilePath, entryFileContent);
module.exports = env => {
return merge(base(env), {
entry: entryFilePath,
output: {
filename: "specs.js",
path: tempDir.path()
}
});
};