Skip to content

Patrickshih/webpack.config-file #128

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

Closed
wants to merge 8 commits into from
Closed

Conversation

shihpatrick
Copy link

@shihpatrick shihpatrick commented Jun 27, 2018

Summary

  • Rewrote build scripts as a webpack.config.js file
  • Changed relevant build scripts to support new config file
  • Utilized environmental variables as flags/parameters to separate and specify builds
    • env.mode = [development | production]
    • env.platform = [node | browser]
    • env.targ = [cjs | umd]
  • upgraded webpack to 3.x, but could not do webpack 4.x because webpack 4.x does not support node4

With a webpack config file, I would be able to simplify the task to add typescript into the Javascript SDK. Also, the config file provides added modularity to the existing codebase.

Test plan

  • Ran npm run build to ensure that dist/ files were being created
  • Built all dist/ files twice (one with webpack.config.js file, one with master) and diff each of them
    • Expected: no difference between each file
    • Actual: Some noticeable differences. Discussed with @spencerwilson-optimizely, and the differences could be because of the upgrade from webpack 2.x.x to 4.x.x. Concluded that these differences should not affect the functional outcome.
    • Example of a diff-*.txt file (diff-cjs.txt):
      image

Copy link
Contributor

@spencerwilson-optimizely spencerwilson-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray, looks great!

"build-dev-umd": "webpack lib/index.browser.js dist/optimizely.browser.umd.js --output-library=optimizelyClient --output-library-target=umd",
"build-prod-cjs": "webpack -p lib/index.browser.js dist/optimizely.browser.cjs.min.js --output-library-target=commonjs",
"build-prod-umd": "webpack -p lib/index.browser.js dist/optimizely.browser.umd.min.js --output-library=optimizelyClient --output-library-target=umd",
"build-node-dev": "webpack --env.mode=development --env.platform=node --env.targ=cjs",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd probably like to rename the env option to --env.target rather than targ, since abbreviations can add unnecessary complexity.

@spencerwilson-optimizely
Copy link
Contributor

I think these changes were obviated by #135. Going to close this.

@spencerwilson-optimizely spencerwilson-optimizely deleted the patrickshih/webpack branch June 29, 2018 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants