【发布时间】:2019-03-29 22:41:46
【问题描述】:
在我的 angularJs 1.3 应用程序中,我之前使用的是 bower 和 grunt,它运行良好。我在 index.html 中添加文件,如下图所示。但现在我已经使用 NPM 安装了所有包,并使用 WEBPack 4.21.0 来捆绑和运行应用程序。但是现在如果我从 Index.html 文件中删除包链接,我的应用程序将停止工作。但我不想要 Index.html 中的所有这些链接,只想从这些文件中生成一个捆绑文件。请指导我如何实现这一目标?目前,它只是在 vendor.js 中添加 angular.js 文件和一些其他文件。
Index.html
Package.json
webpack.config.js
更新问题:
现在我正在使用以下 webpack.config.js 但它正在创建 bootstrap_and_some_plugin.css.js 。它必须创建css文件但不知道为什么要创建js文件?
module.exports = {
context: __dirname + '/app/scripts',
resolve: {
modules: ['bower_components', 'node_modules'],
alias: {
bower_components: __dirname + '/app/bower_components',
assets: __dirname + '/app/assets'
},
extensions: ['.js', '.jsx', '.css']
},
module: {
rules: [
{
test: /\.css$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader" }
]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}]
}
]
},
entry: {
app: './main-app.js',
'bootstrap_and_some_plugin.css': [
'bower_components/font-awesome/css/font-awesome.css',
'bower_components/seiyria-bootstrap-slider/dist/css/bootstrap-slider.min.css',
'bower_components/angular-ui-tree/dist/angular-ui-tree.min.css',
]
},
output: {
filename: '[name].js',
path: __dirname + '/app/scripts',
//chunkFilename: '[id].[chunkhash].js',
},
devServer: {
contentBase: './app',
host: 'localhost',
port: '9000',
inline: true,
compress: true,
proxy: {
'/api/**': {
//target: 'http://10.189.1.159:8080',
target: 'http://localhost:9100',
secure: false,
changeOrigin: true,
cookieDomainRewrite: true
}
},
open: true
},
plugins: [
]
};
【问题讨论】:
标签: angularjs webpack webpack-4