DevVersion 的答案可能比这个更最新
我的解决方案:
您只选择您想要的组件,通过从angular material git repository 进行自定义 angularjs 构建,如下所示
用于自定义 js 构建
在“\gulp”文件夹中编辑util.js,更新buildJs()函数
function buildJs () {
// original code commented
//var jsFiles = config.jsBaseFiles.concat([path.join(config.paths, '*.js')]);
var jsFiles = config.jsBaseFiles;
//adding the paths of components you want
jsFiles.push('src/components/icon/**/*.js');
jsFiles.push('src/components/showHide/**/*.js');
jsFiles.push('src/components/virtualRepeat/**/*.js');
jsFiles.push('src/components/dialog/**/*.js');
- 运行“gulp build”并在“\dist”文件夹中找到js文件
我在 webpack 中使用 angularjs,我在我的应用程序中将“angular-material.js”复制到“\node_modules\angular-material”,并且无需任何更改即可构建。
用于构建自定义 css
在存储库的“\gulp\tasks”文件夹中编辑“build-scss.js”。编辑 getPaths() 函数
function getPaths () {
var paths = config.scssBaseFiles.slice();
if ( modules ) {
paths.push.apply(paths, modules.split(',').map(function (module) {
return 'src/components/' + module + '/*.scss';
}));
} else {
// original code commented
// paths.push('src/components/**/*.scss');
paths.push('src/core/services/layout/**/*.scss');
//add the paths of components you want
paths.push('src/components/icon/**/*.scss');
paths.push('src/components/showHide/**/*.scss');
paths.push('src/components/virtualRepeat/**/*.scss');
paths.push('src/components/datepicker/**/*.scss');
paths.push('src/components/autocomplete/**/*.scss');
paths.push('src/components/backdrop/**/*.scss');
paths.push('src/components/dialog/**/*.scss');
- “gulp build”也会在“\dist”文件夹中构建css
希望对您有所帮助,如果 angular material gulp build 发生更改,请发表评论。
其他方式
当您使用 npm 安装 angularjs 时,您可以在 "\node_modules\angular-material\modules\js" 中找到每个组件的 js 和 css 文件,您可以使用自定义构建来连接它们。