Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 本地视频将不会加载-网页包_Javascript_Reactjs_Webpack_Create React App - Fatal编程技术网

Javascript 本地视频将不会加载-网页包

Javascript 本地视频将不会加载-网页包,javascript,reactjs,webpack,create-react-app,Javascript,Reactjs,Webpack,Create React App,我无法加载/播放一个简单的视频,所以我决定尝试查看网页文件,它看起来很好。代码如下 const autoprefixer = require('autoprefixer'); const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CaseSensitivePathsPlugin = requi

我无法加载/播放一个简单的视频,所以我决定尝试查看网页文件,它看起来很好。代码如下

const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');

const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
const host = process.env.HOST || '0.0.0.0';
const port = parseInt(process.env.PORT, 10) || 3000;
const publicPath = `${protocol}://${host}:${port}/`;

const publicUrl = '';
const env = getClientEnvironment(publicUrl);

module.exports = {
    devtool: 'cheap-module-source-map',
    entry: [
        require.resolve('./polyfills'),
        require.resolve('webpack-dev-server/client') + `?${publicPath}`,
        require.resolve('webpack/hot/dev-server'),
        paths.appIndexJs,
    ],
    output: {
        pathinfo: true,
        filename: 'static/js/bundle.js',
        chunkFilename: 'static/js/[name].chunk.js',
        publicPath: publicPath,
        devtoolModuleFilenameTemplate: info =>
            path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
    },
    resolve: {
        modules: ['node_modules', paths.appNodeModules].concat(
            process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
        ),
        extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
        alias: {
            'react-native': 'react-native-web',
        },
        plugins: [
            new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
        ],
    },
    module: {
        strictExportPresence: true,
        rules: [
            {
                test: /\.(js|jsx|mjs)$/,
                enforce: 'pre',
                use: [
                    {
                        options: {
                            formatter: eslintFormatter,
                            eslintPath: require.resolve('eslint'),  
                        },
                        loader: require.resolve('eslint-loader'),
                    },
                ],
                include: paths.appSrc,
            },
            {
                oneOf: [
                    {
                        test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
                        loader: require.resolve('url-loader'),
                        options: {
                            limit: 10000,
                            name: 'static/media/[name].[hash:8].[ext]',
                        },
                    },
                    {
                        test: /\.(js|jsx|mjs)$/,
                        include: paths.appSrc,
                        loader: require.resolve('babel-loader'),
                        options: {
                            cacheDirectory: true,
                        },
                    },
                    {
                        test: /\.css$/,
                        use: [
                            require.resolve('style-loader'),
                            {
                                loader: require.resolve('css-loader'),
                                options: {
                                    importLoaders: 1,
                                },
                            },
                            {
                                loader: require.resolve('postcss-loader'),
                                options: {
                                    ident: 'postcss',
                                    plugins: () => [
                                        require('postcss-flexbugs-fixes'),
                                        autoprefixer({
                                            browsers: [
                                                '>1%',
                                                'last 4 versions',
                                                'Firefox ESR',
                                                'not ie < 9', // React doesn't support IE8 anyway
                                            ],
                                            flexbox: 'no-2009',
                                        }),
                                    ],
                                },
                            },
                        ],
                    },
                    {
                        test: /\.(html)$/,
                        loader: require.resolve('html-loader'),
                    },
                    {
                        test: /\.mp4$/,
                        use: [
                            {
                                loader: require.resolve('file-loader'),
                                options: {
                                    name: 'static/media/[name].[hash:8].[ext]'
                                }  
                            }
                        ]
                    },
                    {
                        exclude: [/\.js$/, /\.html$/, /\.json$/],
                        loader: require.resolve('file-loader'),
                        options: {
                            name: 'static/media/[name].[hash:8].[ext]',
                        },
                    },
                ],
            },
        ],
    },
    plugins: [
        new InterpolateHtmlPlugin(env.raw),
        new HtmlWebpackPlugin({
            inject: true,
            template: paths.appHtml,
        }),
        new webpack.NamedModulesPlugin(),
        new webpack.DefinePlugin(env.stringified),
        new webpack.HotModuleReplacementPlugin(),
        new CaseSensitivePathsPlugin(),
        new WatchMissingNodeModulesPlugin(paths.appNodeModules),
        new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
    ],
    node: {
        dgram: 'empty',
        fs: 'empty',
        net: 'empty',
        tls: 'empty',
        child_process: 'empty',
    },
    performance: {
        hints: false,
    },
    target: 'node-webkit',
};
const autoprefixer=require('autoprefixer');
const path=require('path');
const webpack=require('webpack');
const HtmlWebpackPlugin=require('html-webpack-plugin');
const CaseSensitivePathsPlugin=require('case-sensitive-path-webpack-plugin');
const InterpolateHtmlPlugin=require('react-dev-utils/InterpolateHtmlPlugin');
const watchmissingdemodulesplugin=require('react-dev-utils/watchmissingdemodulesplugin');
const eslintFormatter=require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin=require('react-dev-utils/ModuleScopePlugin');
const getClientEnvironment=require('./env');
常量路径=需要('./路径');
const protocol=process.env.HTTPS==='true'?'https':'http';
const host=process.env.host | |“0.0.0.0”;
const port=parseInt(process.env.port,10)| 3000;
const publicPath=`${protocol}://${host}:${port}/`;
const publicUrl=“”;
const env=getClientEnvironment(publicUrl);
module.exports={
devtool:“廉价模块源映射”,
条目:[
require.resolve(“./polyfills”),
require.resolve('webpack-dev-server/client')+`?${publicPath}`,
require.resolve('webpack/hot/dev server'),
path.appIndexJs,
],
输出:{
是的,
文件名:“static/js/bundle.js”,
chunkFilename:'static/js/[name].chunk.js',
publicPath:publicPath,
devtoolModuleFilenameTemplate:info=>
解析(info.absoluteResourcePath).replace(/\\\/g,'/'),
},
决心:{
模块:['node_modules',path.appNodeModules].concat(
process.env.NODE\u PATH.split(PATH.delimiter).filter(布尔值)
),
扩展名:['.web.js'、'.mjs'、'.js'、'.json'、'.web.jsx'、'.jsx'],
别名:{
“反应本机”:“反应本机web”,
},
插件:[
新的ModuleScopePlugin(path.appSrc[path.appPackageJson]),
],
},
模块:{
StrightExportPresence:没错,
规则:[
{
测试:/\(js | jsx | mjs)$/,
强制执行:“预”,
使用:[
{
选项:{
格式化程序:eslintFormatter,
eslintPath:require.resolve('eslint'),
},
loader:require.resolve('eslint-loader'),
},
],
包括:path.appSrc,
},
{
其中一项:[
{
测试:[/\.bmp$/,/\.gif$/,/\.jpe?g$/,/\.png$/],
加载器:require.resolve('url-loader'),
选项:{
限额:10000,
名称:'static/media/[name].[hash:8].[ext]',
},
},
{
测试:/\(js | jsx | mjs)$/,
包括:path.appSrc,
loader:require.resolve('babel-loader'),
选项:{
cacheDirectory:true,
},
},
{
测试:/\.css$/,,
使用:[
require.resolve('style-loader'),
{
加载器:require.resolve('css-loader'),
选项:{
进口装载机:1,
},
},
{
加载器:require.resolve('postss-loader'),
选项:{
标识:'邮政编码',
插件:()=>[
需要('PostSS-flexbugs-fixes'),
自动刷新器({
浏览器:[
'>1%',
“最后4个版本”,
“Firefox ESR”,
'不是ie<9',//React无论如何都不支持IE8
],
flexbox:‘no-2009’,
}),
],
},
},
],
},
{
测试:/\(html)$/,
加载器:require.resolve('html-loader'),
},
{
测试:/\.mp4$/,,
使用:[
{
加载器:require.resolve('file-loader'),
选项:{
名称:'static/media/[name].[hash:8].[ext]'
}  
}
]
},
{
排除:[/\.js$/,/\.html$/,/\.json$/],
加载器:require.resolve('file-loader'),
选项:{
名称:'static/media/[name].[hash:8].[ext]',
},
},
],
},
],
},
插件:[
新的EhtmlPlugin(环境原始),
新HtmlWebpackPlugin({
是的,
模板:path.appHtml,
}),
新的webpack.NamedModulesPlugin(),
新网页包。定义插件(env.stri)
import React, { Component } from 'react';
import { curious } from '@curi/react';
import AttractLoop from '../../assets/videos/video.mp4';

class App extends Component {
    render() {
        return (
            <div className="app-container">
                <div className="attract-loop">
                    <video width="1080" height="1920">
                        <source src={ AttractLoop } type="video/mp4" />
                    </video>
                </div>
            </div>
        );
    }
}

export default curious(App);
<video width="1080" height="1920" autoPlay loop src={ AttractLoop } type="video/mp4" />
module.exports = {
  devtool: 'cheap-module-source-map',
  entry: [
    require.resolve('./polyfills'),
    require.resolve('webpack-dev-server/client') + `?${publicPath}`,
    require.resolve('webpack/hot/dev-server'),
    paths.appIndexJs,
  ],
  output: {
    pathinfo: true,
    filename: 'js/bundle.js',
    chunkFilename: 'js/[name].chunk.js',
    // double check that this has it's backslashes in the right place
    path: path.resolve(__dirname, publicPath + '/static'),
    publicPath: publicPath',
    devtoolModuleFilenameTemplate: info =>
      path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
  },
  resolve: {
    modules: ['node_modules', paths.appNodeModules].concat(
      process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
    ),
    extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
    alias: {
      'react-native': 'react-native-web',
    },
    plugins: [
      new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
    ],
  },
  module: {
    strictExportPresence: true,
    rules: [
      {
        test: /\.(js|jsx|mjs)$/,
        enforce: 'pre',
        use: [
          {
            options: {
              formatter: eslintFormatter,
              eslintPath: require.resolve('eslint'),
            },
            loader: require.resolve('eslint-loader'),
          },
        ],
        include: paths.appSrc,
      },
      {
        oneOf: [
          {
            test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
            loader: require.resolve('url-loader'),
            options: {
              limit: 10000,
              //name: 'static/media/[name].[hash:8].[ext]',
              name: 'media/[name].[hash:8].[ext]',
            },
          },
          {
            test: /\.(js|jsx|mjs)$/,
            include: paths.appSrc,
            loader: require.resolve('babel-loader'),
            options: {
              cacheDirectory: true,
            },
          },
          {
            test: /\.css$/,
            use: [
              require.resolve('style-loader'),
              {
                loader: require.resolve('css-loader'),
                options: {
                  importLoaders: 1,
                },
              },
              {
                loader: require.resolve('postcss-loader'),
                options: {
                  ident: 'postcss',
                  plugins: () => [
                    require('postcss-flexbugs-fixes'),
                    autoprefixer({
                      browsers: [
                        '>1%',
                        'last 4 versions',
                        'Firefox ESR',
                        'not ie < 9', // React doesn't support IE8 anyway
                      ],
                      flexbox: 'no-2009',
                    }),
                  ],
                },
              },
            ],
          },
          {
            test: /\.(html)$/,
            loader: require.resolve('html-loader'),
          },
          {
            test: /\.mp4$/,
            use: [
              {
                loader: require.resolve('file-loader'),
                options: {
                  //name: 'static/media/[name].[hash:8].[ext]'
                  name: 'media/[name].[hash:8].[ext]'
                }
              }
            ]
          },
          {
            exclude: [/\.js$/, /\.html$/, /\.json$/],
            loader: require.resolve('file-loader'),
            options: {
              //name: 'static/media/[name].[hash:8].[ext]',
              name: 'media/[name].[hash:8].[ext]',
            },
          },
        ],
      },
    ],
  },
  plugins: [
    new InterpolateHtmlPlugin(env.raw),
    new HtmlWebpackPlugin({
      inject: true,
      template: paths.appHtml,
    }),
    new webpack.NamedModulesPlugin(),
    new webpack.DefinePlugin(env.stringified),
    new webpack.HotModuleReplacementPlugin(),
    new CaseSensitivePathsPlugin(),
    new WatchMissingNodeModulesPlugin(paths.appNodeModules),
    new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
  ],
  node: {
    dgram: 'empty',
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
    child_process: 'empty',
  },
  performance: {
    hints: false,
  },
  target: 'node-webkit',
};