@aappddeevv/scalajs-loader 中文文档教程
Scala.js Webpack loader
这是 https://github.com/mrdziuban/scalajs-loader< 的更新版本/a>。
Usage
这是一个简单的 Webpack 加载程序,它向 SBT 发送外壳以构建一个 Scala.js 项目。
要使用它,首先安装包:
$ npm install --save scalajs-loader
然后在您的 Webpack 配置中配置加载器:
module.exports = {
// ...
module: {
rules: [
{ test: /\.scala$/, loader: 'scalajs-loader' },
// ...
]
}
}
确保您在 PATH
中的某处有 sbt
二进制文件。
Example
查看 example 目录以获取简单的 Hello World 示例。
Options
可以提供选项来指定 scalajs 阶段、fullOptJS 或 fastOptJS。
... as above ...
{
test: /\.scala$/,
loader: 'scaljs-loader',
options: {
jsStage: 'fullOptJS',
clean: true
}
}
一个附加选项 dirSegment
在标准之后附加一个目录段 scalajs 目标输出目录(例如 target/scala-2.12),以防你 使用像 scalajs-bundler 这样的 sbt 插件来改变输出目录。
为了减少构建时间,您可能希望为开发工作和运行保持 clean: false
仅为生产构建清理。
所有选项:
- verbose: Print messages during processing.
- clean: Clean prior to build.
- dirSegment: Directory segment inserted into the constructed path to find the .js file.
- removeSoruceMapUrl: Remove the source map URL.
- jsStage: "fastOptJS" or or "opt"
Scala.js Webpack loader
This is an updated version from https://github.com/mrdziuban/scalajs-loader.
Usage
This is a simple Webpack loader that shells out to SBT to build a Scala.js project.
To use it, first install the package:
$ npm install --save scalajs-loader
then configure the loader in your Webpack config:
module.exports = {
// ...
module: {
rules: [
{ test: /\.scala$/, loader: 'scalajs-loader' },
// ...
]
}
}
Make sure you have the sbt
binary somewhere in your PATH
.
Example
Check out the example directory for a simple Hello World example.
Options
Options can be provided to specify the scalajs stage, fullOptJS or fastOptJS.
... as above ...
{
test: /\.scala$/,
loader: 'scaljs-loader',
options: {
jsStage: 'fullOptJS',
clean: true
}
}
An additional option dirSegment
appends a directory segment after the standard scalajs target output directory (such as target/scala-2.12) in case you are using a sbt plugin like scalajs-bundler that alters the output directory.
To reduce build times, you may want to keep clean: false
for dev work and run clean only for the production build.
All options:
- verbose: Print messages during processing.
- clean: Clean prior to build.
- dirSegment: Directory segment inserted into the constructed path to find the .js file.
- removeSoruceMapUrl: Remove the source map URL.
- jsStage: "fastOptJS" or or "opt"