在Agnular 6版本的angular-cli中,看来我无法使用某些webpack功能来完成以前的工作,特别是使用诸如'require'之类的插件以及针对我们的流程编写的自定义
据我所知,“ ng弹出”功能可以使我做到这一点 已禁用以减少angular-cli的学习曲线。
在我的Angular 6 non-cli库构建中,我有以下代码片段:
webpack.config.js
解决:{ 扩展名:['.webpack.js','。web.js','。ts','。js','。css','。scss,>'.html'], 别名:{ 'mycode':path.resolve(__ dirname,'./webpack/mycode'), }, }
插件:[ 新的webpack.ProvidePlugin({ 'mycode':'mycode', }), ...插件 ]
目录结构代码段
projectRoot | +-webpack | +-loaders.js +-plugins.js +-postcss.js +-mycode.js
Mycode.js看起来像这样:
const escape = require('escape-html');
module.exports = { showCode:function showCode(code){ 返回转义码 .replace(/}} / g,'}}'); }, runCode:function runCode(code){ 返回码; }, };
最后,所有这些都通过将文件包含在较大的文件中来使用:
$ {mycode.runCode(require('./ documentation.html'))}
示例
徽章类型
$ {mycode.showCode(require('./ badge1.html'))}
$ {mycode.runCode(require('./ badge1.html'))}>
标准宽度和高度
$ {mycode.showCode(require('./ badge2.html'))}
$ {mycode.runCode(require('./ badge2.html'))}>
展开和填充/宽度和高度
$ {mycode.showCode(require('./ badge3.html'))}
$ {mycode.runCode(require('./ badge3.html'))}
我认为,只要我能传达自己的意图,webpack就会做正确的事情。我真的很想看看这是否可行,然后再重写所有示例。
想法?