Skip to content

Commit

Permalink
Merge pull request #21 from ChuckJonas/windows
Browse files Browse the repository at this point in the history
Windows & removal or local mode
  • Loading branch information
ChuckJonas authored Apr 18, 2019
2 parents e7b7366 + 5b1a86c commit 555ee40
Show file tree
Hide file tree
Showing 19 changed files with 285 additions and 1,241 deletions.
22 changes: 0 additions & 22 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# EditorConfig is awesome: http://EditorConfig.org
# vscode extension: https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig

# top-most EditorConfig file
root = true
Expand Down
9 changes: 7 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
"type": "chrome",
"request": "launch",
"sourceMaps": true,
"url": "http://localhost:8080",
"url": "https://c.na73.visual.force.com/apex/app?local=1",
"webRoot": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart",
"skipFiles": [
"node_modules/**"
],
"runtimeArgs": [
"--remote-debugging-port=9222", //Open in port 9222 (standard chrome debug port)
"--allow-insecure-localhost=1"
],
"sourceMapPathOverrides": {
"webpack:///*": "${webRoot}/*"
}
},
"smartStep": true
}
]
}
142 changes: 57 additions & 85 deletions README.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions config/babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"presets": [
"@babel/env",
"@babel/typescript",
"@babel/react"

],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["react-hot-loader/babel"],
[
"import",
{
"libraryName": "antd",
"style": true,
"libraryDirectory": "es"
}
],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["@babel/proposal-object-rest-spread"]
]
}
7 changes: 7 additions & 0 deletions config/cert/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Trusting Localhost

For cases where you cannot `Allow Insecure Localhost` (or aren't using chrome):

1. run `openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout ./config/cert/server.key -out ./config/cert/server.crt -extensions san -config ./config/cert/dev.conf`
2. in "package.json" update the `npm start` with `--cert ./config/cert/server.crt --key ./config/cert/server.key`
3. install the newly created cert `config/cert/server.crt` in [keychain and set trust to "Always"](https://www.youtube.com/watch?v=TGrX8XgSuZ4)
15 changes: 0 additions & 15 deletions config/index.html

This file was deleted.

3 changes: 2 additions & 1 deletion jest.json → config/jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"transform": {
"\\.(ts|tsx)$": "ts-jest"
},
"rootDir": "../",
"moduleNameMapper": {
"\\.(css|scss|less)$": "<rootDir>/config/__mocks__/styleMock.js",
"\\.(png|jpg|gif|ttf|eot|svg)$": "<rootDir>/config/__mocks__/fileMock.js",
"@src/(.*)": "<rootDir>/src/$1",
"@gen/(.*)": "<rootDir>/src/generated/$1"
},
"testRegex": "/tests/.*\\.(ts|tsx|js)$",
"testRegex": "/src/tests/.*\\.(ts|tsx|js)$",
"unmockedModulePathPatterns": []
}
9 changes: 0 additions & 9 deletions config/sfdc-cors-disable/destructiveChanges.xml

This file was deleted.

4 changes: 0 additions & 4 deletions config/sfdc-cors-disable/package.xml

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions config/sfdc-cors-enable/package.xml

This file was deleted.

48 changes: 17 additions & 31 deletions config/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,38 @@ import * as path from 'path';
import * as webpack from 'webpack';
import * as webpackDevServer from 'webpack-dev-server';
import * as fs from 'fs';

const DashboardPlugin = require('webpack-dashboard/plugin');
import lessToJs from 'less-vars-to-js';
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const HtmlWebpackPlugin = require('html-webpack-plugin');

/** Setup Paths */
const PATHS = {
root: path.resolve(__dirname, '..'),
nodeModules: path.resolve(__dirname, '../node_modules'),
src: path.resolve(__dirname, '../src'),
assets: path.resolve(__dirname, '../src/assets'),
dist: path.resolve(__dirname, '../dist'),
styles: path.resolve(__dirname, '../src/styles'),
localTemplate: path.resolve(__dirname, '../config/index.html'),
styles: path.resolve(__dirname, '../src/styles')
};

// for ant overrides

const lessToJs = require('less-vars-to-js');
// for ant style overrides
const themeVariables = lessToJs(fs.readFileSync(path.join(PATHS.styles, './ant-theme-vars.less'), 'utf8'));

module.exports = (env: any = {}) => {
const PORT = env.port || 8080; // should match ./config/sfdc-cors-enable
const resourceName = env.resource || 'app';
const isBuild = !!env.build;
const isLocal = env.local;

console.log('isBuild:', isBuild, 'isLocal:', isLocal);
console.log(`Resource Name: ${resourceName} | isBuild: ${isBuild}`);

const mode = isBuild ? 'production' : 'development';

// add things here to put in the global namespace
const GLOBAL_DEFINES: any = {
'process.env': {
NODE_ENV: JSON.stringify(mode),
},
};

const DEV_SERVER: webpackDevServer.Configuration = {
const devServer: webpackDevServer.Configuration = {
historyApiFallback: true,
overlay: true,
port: PORT,
Expand All @@ -50,21 +45,11 @@ module.exports = (env: any = {}) => {
disableHostCheck: true,
};

// Setup variables for communications with Salesforce locally
if (isLocal) {
// get access token from sfdx
const child_process = require('child_process');
const orgInfo = JSON.parse(child_process.execSync('sfdx force:org:display --json').toString('utf8'));
console.log(`Running on ${orgInfo.result.instanceUrl} as ${orgInfo.result.username}`);
GLOBAL_DEFINES.__ACCESSTOKEN__ = JSON.stringify(orgInfo.result.accessToken);
GLOBAL_DEFINES.__RESTHOST__ = JSON.stringify(orgInfo.result.instanceUrl);
}

const config: webpack.Configuration = {
mode,
cache: true,
devtool: isBuild ? 'source-map' : 'eval-source-map',
devServer: DEV_SERVER,
devtool: isBuild ? 'source-map' : 'source-map',
devServer,
context: PATHS.root,
entry: {
app: [
Expand All @@ -75,7 +60,10 @@ module.exports = (env: any = {}) => {
output: {
path: PATHS.dist,
filename: '[name].js',
publicPath: (isBuild ? `/resource/${resourceName}/dist/` : isLocal ? '/' : `https://localhost:${PORT}/`), // setup for HMR when hosted with salesforce
publicPath: (
isBuild ? `/resource/${resourceName}/dist/`
: `https://localhost:${PORT}/` // setup for HMR when hosted with salesforce
),
},
optimization: {
splitChunks: {
Expand All @@ -98,6 +86,8 @@ module.exports = (env: any = {}) => {
// externals: {
// },


/*** LOADERS ***/
module: {
rules: [
// typescript
Expand All @@ -106,6 +96,7 @@ module.exports = (env: any = {}) => {
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: require('./babelrc.json')
},
// css
{
Expand Down Expand Up @@ -164,19 +155,14 @@ module.exports = (env: any = {}) => {
],
},

/*** PLUGIN ***/
plugins: [
...[
new webpack.DefinePlugin(GLOBAL_DEFINES),
],
...(!isBuild ? [
new DashboardPlugin(),
new webpack.NamedModulesPlugin(),
] : []),
...(isLocal ? [
new HtmlWebpackPlugin({
template: PATHS.localTemplate,
}),
] : []),
...(env.analyze ? [
new BundleAnalyzerPlugin(),
] : []),
Expand Down
Loading

0 comments on commit 555ee40

Please sign in to comment.