Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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
替换<;脚本src=jquery.js>;通过混合应用程序(AngularJS-Angular)et网页中的节点_模块_Jquery_Angularjs_Angular_Webpack 4_Ts Loader - Fatal编程技术网

替换<;脚本src=jquery.js>;通过混合应用程序(AngularJS-Angular)et网页中的节点_模块

替换<;脚本src=jquery.js>;通过混合应用程序(AngularJS-Angular)et网页中的节点_模块,jquery,angularjs,angular,webpack-4,ts-loader,Jquery,Angularjs,Angular,Webpack 4,Ts Loader,我面临着一个每个人都遇到过的问题,但尽管提出了所有的解决方案,没有一个能解决我的问题 实际上,我们有一个混合应用程序(AngularJS和Angular8),使用Webpack4和ts加载器。我们用tag加载了所有的库,一切都很好 我的实际工作是删除这些脚本标记,并改为设置node_模块。 除了jquery之外,其他一切都正常工作 事实上,在开发模式下,这是可以的,因为我使用devtool:“eval source map”,在这种情况下,jquery到处都可以找到,但当我想在生产模式下生成捆绑

我面临着一个每个人都遇到过的问题,但尽管提出了所有的解决方案,没有一个能解决我的问题

实际上,我们有一个混合应用程序(AngularJS和Angular8),使用Webpack4和ts加载器。我们用tag加载了所有的库,一切都很好

我的实际工作是删除这些脚本标记,并改为设置node_模块。 除了jquery之外,其他一切都正常工作

事实上,在开发模式下,这是可以的,因为我使用devtool:“eval source map”,在这种情况下,jquery到处都可以找到,但当我想在生产模式下生成捆绑文件而不使用源映射时,jquery就再也找不到了

事实上,使用源代码映射使文件变得相当大

这是我的网页配置:

const path = require('path');
const webpack = require('webpack');

module.exports = {
    entry: {
        app: path.join(__dirname, '/main.ts'),
        dashboard: path.join(__dirname, '/main.dashboard.ts'),
    },
    // devtool: 'eval-source-map',
    output: {
        filename: '[name].bundle.js',
        publicPath: "/dist",
        pathinfo: true,
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                loader: 'ts-loader',
                exclude: /node_modules/,
            },
            {
                test: /\.(html)$/,
                use: {
                    loader: 'html-loader',
                }
            },
            {
                test: /\.css/i,
                use: [
                    'style-loader',
                    'css-loader'
                ]
            },
            {
                test: /\.(png|woff|woff2|eot|ttf|svg)$/,
                loader: 'url-loader?limit=100000'
            }
        ]
    },
    plugins: [
        new webpack.ContextReplacementPlugin(
            /(.+)?angular(\/)core(.+)?/,
            path.join(__dirname, '/'), //location of src
            {} //a map of our routes
        ),
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery'
        })
    ],
    resolve: {
        extensions: [".webpack.js", ".web.js", ".tsx", ".ts", ".js"]
    }
};
在my package.json文件中:

"dependencies": {
...
    "jquery": "^3.1.0"
  },
"devDependencies": {
    "@types/jquery": "^3.3.31"
  },
任何帮助都将不胜感激,
提前感谢您,

将jQuery添加到
angular.json
。找到属性“scripts”(您可能有多个脚本)并添加


(或兼容,具体取决于jQuery的dist的实际路径)。

感谢您的回复,您的意思是在angular node_模块的package.json中?我们实际上处于混合模式,我们没有使用angularCLI将angular添加到现有项目中,因此我的项目中没有任何angular.json文件哦。这稍微改变了一些,因为这是一种将第三方脚本添加到Angular应用程序的方式。那么,如果没有angular cli提供的所有优点,您如何构建应用程序?手动,负责该应用程序的文件如下:
import{NgModule}from“@angular/core”;导入@NgModule({imports:[BrowserModule,UpgradeModule]})导出类AppModule{ngDoBootstrap(){}}platformBrowserDynamic().bootstrapModule(AppModule)
"scripts": [ "../node_modules/jquery/dist/jquery.min.js" ]