| # Copyright 2019 The Bazel Authors. All rights reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| workspace( |
| name = "examples_vendored_node", |
| managed_directories = {"@npm": ["npm/node_modules"]}, |
| ) |
| |
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| |
| http_archive( |
| name = "build_bazel_rules_nodejs", |
| sha256 = "9901bc17138a79135048fb0c107ee7a56e91815ec6594c08cb9a17b80276d62b", |
| urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.40.0/rules_nodejs-0.40.0.tar.gz"], |
| ) |
| |
| http_archive( |
| name = "vendored_node_10_12_0", |
| build_file_content = """exports_files(["node-v10.12.0-linux-x64/bin/node"])""", |
| sha256 = "4eba2e9a6db95745b769915d58e57df6ca6724ec1f023f76556fce30ceca2367", |
| urls = ["https://nodejs.org/dist/v10.12.0/node-v10.12.0-linux-x64.tar.xz"], |
| ) |
| |
| load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "npm_install") |
| |
| # This example only works on linux as it downloads the linux node distribution |
| # TODO(gregmagolan): make node_repositories acccept different archives for different platforms |
| node_repositories( |
| node_version = "10.12.0", |
| vendored_node = "@vendored_node_10_12_0//:node-v10.12.0-linux-x64", |
| ) |
| |
| npm_install( |
| name = "npm", |
| data = [ |
| "@vendored_node_10_12_0//:node-v10.12.0-linux-x64/bin/node", |
| ], |
| package_json = "//:package.json", |
| package_lock_json = "//:package-lock.json", |
| ) |
| |
| load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies") |
| |
| install_bazel_dependencies() |