按照@Kaspar Scherrer 的回答,我能够通过执行以下步骤生成 Twitter Bootstrap 的自定义构建,以将其作为 CSS 包含在我的 Vaadin 14 应用程序中:
通过 npm 包含 Bootstrap 的源 Sass 和 JavaScript 文件,npm install bootstrap
在项目根目录中的 CLI 上运行;
在我的项目上设置libsass-maven-pluginpom.xml
:
<!-- SASS compiler -->
<plugin>
<groupId>com.gitlab.haynes</groupId>
<artifactId>libsass-maven-plugin</artifactId>
<version>0.2.21</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<inputPath>${basedir}/src/main/webapp/frontend/sass/</inputPath>
<includePath>${basedir}/node_modules/</includePath>
<outputPath>${basedir}/src/main/webapp/frontend/css/</outputPath>
<failOnError>true</failOnError>
</configuration>
</plugin>
- 在 dir set on 中创建了自定义 SASS 文件,
webapp-bootstrap.scss
在本例中命名为inputPath
:
html {
box-sizing: border-box;
-ms-overflow-style: scrollbar;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
// Required
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/mixins/breakpoints";
@import "bootstrap/scss/mixins/clearfix";
@import "bootstrap/scss/mixins/deprecate";
@import "bootstrap/scss/mixins/grid-framework";
@import "bootstrap/scss/mixins/grid";
@import "bootstrap/scss/mixins/hover";
@import "bootstrap/scss/mixins/screen-reader";
@import "bootstrap/scss/mixins/text-emphasis";
@import "bootstrap/scss/mixins/text-hide";
@import "bootstrap/scss/mixins/text-truncate";
// Optional
@import "bootstrap/scss/grid";
@import "bootstrap/scss/utilities/align";
@import "bootstrap/scss/utilities/clearfix";
@import "bootstrap/scss/utilities/display";
@import "bootstrap/scss/utilities/flex";
@import "bootstrap/scss/utilities/float";
@import "bootstrap/scss/utilities/position";
@import "bootstrap/scss/utilities/screenreaders";
@import "bootstrap/scss/utilities/sizing";
@import "bootstrap/scss/utilities/spacing";
@import "bootstrap/scss/utilities/text";
- 通过使用注释在我的应用程序中包含生成的样式表
@StyleSheet("css/webapp-bootstrap.css")
。