我将 webpack 与HtmlWebpackPlugin,html-loader和file-loader. 我有一个简单的项目结构,其中不使用框架,而只使用打字稿。因此,我将 HTML 代码直接写入index.html. 我也使用这个 HTML 文件作为我的模板HtmlWebpackPlugin。
和所有网站一样,我需要在我的资产文件夹中放置一个引用 PNG 的图像。file-loader应该正确加载文件,将新文件名放在src标签内,但这不是正在发生的事情。相反,作为src标签的值,我有[object Module]. 我假设它file-loader发出一些对象,当它的.toString()方法运行时它是这样表示的。但是,我可以看到file-loader已成功处理文件并以新名称发送到输出路径。我没有错误。这是我的 webpack 配置和index.html.
const projectRoot = path.resolve(__dirname, '..');
{
entry: path.resolve(projectRoot, 'src', 'app.ts'),
mode: 'production',
output: {
path: path.resolve(projectRoot, 'dist'),
filename: 'app.bundle.js'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.html$/i,
use: 'html-loader'
},
{
test: …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的 Angular 8 应用程序中实现Swiper:https : //swiperjs.com/get-started/。
我在我的资产文件夹中创建了一个 javascript 文件并将它包含到我的angular.json.
此外,我在我的中包含了Swiperapp.module.ts并运行了命令
npm install @types/swiper.
但是,我收到错误:
[ts] Module '"../node_modules/@types/swiper/index has no exported member 'Swiper'
当它清楚地这样做时。我不确定我哪里出错了。
card-swipe.component.ts
import { SwiperModule, SwiperConfigInterface } from 'ngx-swiper-wrapper';
@Component({
selector: 'app-card-swipe',
templateUrl: './card-swipe.component.html',
styleUrls: ['./card-swipe.component.css']
})
export class CardSwipeComponent implements OnInit {
constructor() { }
something;
index;
config: SwiperConfigInterface = {
a11y: true,
direction: 'horizontal',
slidesPerView: 3,
slideToClickedSlide: true,
mousewheel: true,
scrollbar: false,
watchSlidesProgress: true,
navigation: true, …Run Code Online (Sandbox Code Playgroud)