Javascript 为什么webpack加载多个app.js文件而不是单个app.js文件
我使用webpack创建了一个没有CLI的angular应用程序。一切正常。但当我调试它时,我发现我的app.js文件被多次加载 下面是我的webpack.config.js文件Javascript 为什么webpack加载多个app.js文件而不是单个app.js文件,javascript,angular,webpack,Javascript,Angular,Webpack,我使用webpack创建了一个没有CLI的angular应用程序。一切正常。但当我调试它时,我发现我的app.js文件被多次加载 下面是我的webpack.config.js文件 const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const ScriptExtPlugin = require('script-ext
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ScriptExtPlugin = require('script-ext-html-webpack-plugin');
const { AngularCompilerPlugin } = require('@ngtools/webpack');
var path = require('path');
module.exports = function () {
return {
//entry: './src/main.ts',
entry: {
// vendor: './src/vendor.ts',
polyfills: './src/polyfills.ts',
main: './src/main.ts'
},
output: {
path: __dirname + '/src',
publicPath: "/",
filename: 'app.js'
},
watch: true,
resolve: {
extensions: ['.ts', '.js']
},
devServer: {
contentBase: path.join(__dirname, 'src'),
watchContentBase: true,
// hot: true,
},
module: {
rules: [
{ test: /\.ts$/, loaders: ['awesome-typescript-loader', 'angular2-template-loader'] },
{
test: /\.html$/,
loader: 'html-loader'
}
]
},
plugins: [
new CopyWebpackPlugin([
{ from: 'src/assets', to: 'assets' }
]),
new HtmlWebpackPlugin({
template: __dirname + '/src/index.html',
output: __dirname + '/dist',
inject: 'head'
}),
new ScriptExtPlugin({
defaultAttribute: 'defer'
}),
new AngularCompilerPlugin({
tsConfigPath: './tsconfig.json',
entryModule: './src/app/app.module#AppModule',
sourceMap: true
})
]
};
}
dirname的值是多少?在Node.js中,_dirname始终是当前正在执行的脚本所在的目录,无需声明