Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install webpack #56

Closed
1 of 4 tasks
omenking opened this issue Nov 8, 2017 · 13 comments
Closed
1 of 4 tasks

install webpack #56

omenking opened this issue Nov 8, 2017 · 13 comments
Assignees
Projects

Comments

@omenking
Copy link
Owner

omenking commented Nov 8, 2017

  • ensure npm run dev runs free without errors
  • ensure npm run build compiles without errors
  • ensure npm run dist builds app and runs without errors
  • ensure test suite /spec runs through webpack
@omenking omenking self-assigned this Nov 8, 2017
@omenking omenking added this to Ready in Dev Board via automation Nov 8, 2017
@omenking omenking moved this from Ready to In Progress in Dev Board Nov 8, 2017
@omenking omenking moved this from In Progress to Blocked in Dev Board Nov 26, 2017
@omenking omenking assigned RauliL and unassigned omenking Nov 26, 2017
@omenking omenking moved this from Blocked to Ready in Dev Board Nov 26, 2017
@RauliL RauliL moved this from Ready to In Progress in Dev Board Nov 27, 2017
@omenking
Copy link
Owner Author

I found this which might be of help
https://medium.com/kendraio/using-angular-with-electron-webpack-b9763903823c

@omenking
Copy link
Owner Author

I can see we are choosing to serve our static file.
I noticed that electron-webpack serves up a file in development from localhost:8090 and this is done in that tutorial I shared

const dev = process.env.NODE_ENV !== 'production';
const pathname = dev ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` : `file://${__dirname}/index.html`;

@omenking
Copy link
Owner Author

It appears the renderer.js file is also served up dynamically.

screen shot 2017-11-27 at 7 34 01 pm

@omenking
Copy link
Owner Author

Dead end doing npm run dev

Went to do
npm run build but got an error
Adding this to my package.json allowed build to work

  "resolutions": {
      "webpack-sources": "1.0.1"
  },

electron-userland/electron-webpack#58

@omenking
Copy link
Owner Author

I can see now why the static file was linked, since when I build like this the url make sense

@omenking
Copy link
Owner Author

I can't get pass this in npm run dev

screen shot 2017-11-27 at 7 54 37 pm

@omenking
Copy link
Owner Author

Works with no issue if pass in the pathname directly.
'''
win.loadURL(pathname)
//win.loadURL(url.format({
//protocol: 'file://',
//pathname: pathname,
//slashes: true,
//icon: path.join(__static, 'icons', 'png', '64x64.png')
//}))
'''

@omenking
Copy link
Owner Author

@RauliL
So I have it the game working for the most part in npm run dev
Unsure how npm run build will need to be adjusted.

There are some things not working correctly such as the UI not opening on ESC and minor things, but in a much better place to debug now.

@omenking
Copy link
Owner Author

UI working as expected now.

I think the tricky part will be to get our tests /spec to run through webpack.

@omenking
Copy link
Owner Author

@omenking
Copy link
Owner Author

electron/electron#5107

@omenking
Copy link
Owner Author

So I ran into cases where we're going to want to open up the webpack config file because the hardcoded source aliases provided by electron-webpack won't work with test code.

So I have it working with the exception that __dirname inside main.js is not correctly resolving.

Its probably for the best we manually configure our webpack.

const path = require('path');
const config_main = {
  target: 'electron-main',
  entry: path.resolve(__dirname, 'src/main/index.js'),
  output: {
    path    : path.resolve(__dirname, 'static'),
    filename: 'main.js'
  },
  externals: [{ 'electron-store': 'require("electron-store")' }],
  resolve: {
    alias: {
      main   : path.resolve(__dirname, 'src/main/'),
      common : path.resolve(__dirname, 'src/common/')
    }
  }
};

const config_renderer = {
  target: 'electron-renderer',
  entry: path.resolve(__dirname, 'src/renderer/index.js'),
  output: {
    path    : path.resolve(__dirname, 'static'),
    filename: 'renderer.js'
  },
  node: {
    __dirname: false
  },
  externals: [{ 'electron-store': 'require("electron-store")' }],
  resolve: {
    alias: {
      components : path.resolve(__dirname, 'src/renderer/components/'),
      core       : path.resolve(__dirname, 'src/renderer/core/'),
      states     : path.resolve(__dirname, 'src/renderer/states/'),
      ui         : path.resolve(__dirname, 'src/renderer/ui/'),
      common     : path.resolve(__dirname, 'src/common/'),
    }
  }
};

module.exports = [
  config_main,
  config_renderer
];

@omenking
Copy link
Owner Author

Turns out I had

  node: {
    __dirname: false
  },

In my renderer config instead of my main config. I will keep my comment above in case anyone likes my config file.

@Skytrias Skytrias moved this from In Progress to Completed in Dev Board Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Dev Board
  
Completed
Development

No branches or pull requests

3 participants