Angularjs 网页包无法解析模块';角度';在其他图书馆
我正在使用Webpack3.1.0来编写我的应用程序,它是用Angular 1编写的。 这是我的webpack.config.js:Angularjs 网页包无法解析模块';角度';在其他图书馆,angularjs,webpack,webpack-3,Angularjs,Webpack,Webpack 3,我正在使用Webpack3.1.0来编写我的应用程序,它是用Angular 1编写的。 这是我的webpack.config.js: const webpack = require('webpack'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const config = { e
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const config = {
entry: './frontend/expert/app/expert.js',
output: {
filename: 'bundle.js',
path: __dirname + '/frontend/expert/dist'
},
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /\.html$/,
use: ['html-loader']
},
{
test: /\.(png|jpg|jpeg|gif|svg)$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'img/',
publicPath: 'img/'
}
}]
},
{
test: /\.(woff|woff2|ttf|eot)$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}]
}
]
},
plugins: [
new ExtractTextPlugin('main.css'),
new HtmlWebpackPlugin({
template: './frontend/expert/app/index.html'
})
],
resolve: {
alias: {
angular: './frontend/expert/bower_components/angular/angular.min.js'
}
}
};
module.exports = config;
My expert.js如下(我从中选择所需的库):
有些模块无法解析“角度”,例如“角度全屏”,我遇到了以下错误:
未找到模块:错误:无法解析“/Users/Bhavesh/myapp/frontend/expert/bower_components/angular fullscreen/src”中的“angular”
我试图通过将alias放在webpack.config.js中的“angular”来解决这个问题,但没有成功
我的应用程序是一个多页应用程序,有两个不同的角度应用程序
其结构如下:
-bin
-models
-routes
-server
-node_modules
-webpack.config.js
-frontend
--expert
--bower_components
--app
--expert.js
--user
--bower_components
--app
有人能帮我解决这个问题吗。我用以下方法解决了这个问题:
{
test: require.resolve('angular'),
use: [
'expose-loader?angular'
]
};
更多详细信息以及如何处理其他第三方库。然后我遇到了以下错误:在Function.module中找不到模块'angular'。\u resolveFilename(module.js:470:15)在Function.resolve(internal/module.js:27:19)at Object中。(/Users/Bhavesh/myapp/webpack.config.js:45:31)您的
webpack.config.js
的第45行是什么?
{
test: require.resolve('angular'),
use: [
'expose-loader?angular'
]
};