這裏是我(簡化)角2 app文件夾stucture:爲什麼Webpack不會複製我的ng2模板文件?
這裏是我的webpack.config.js:
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
'polyfills': './polyfills.ts',
'vendor': './vendor.ts',
'app': './app/main.ts'},
output: {
path: './dist',
filename: '[name].js',
chunkFilename: "[id].bundle.js",
sourcemapFilename: '[name].map'
},
module: {
loaders: [
{test: /\.ts$/, loaders: ['ts', 'angular2-template-loader']},
{
test: /\.html$/,
loader: 'html'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file?name=assets/[name].[hash].[ext]'
},
,{ test: /\.css$/, loaders: 'style!css' }
]
},
resolve: {
extensions: ['', '.js', '.ts']
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
new HtmlWebpackPlugin({
template: './index.html'
})
]
}
當我執行的WebPack構建,DIST文件夾僅獲取index.html,app.js,polyfills.js和vendor.js。 app.component.html,css和用戶組件html文件不會被複制到dist文件夾中(在各個文件夾,應用程序,應用程序/用戶...中)。
我缺少什麼?
編輯:
這是它的外觀,從開發工具:
它看起來像你的templateUrl沒有被遵守。你可以請你分享你的組件代碼 –
'@Component({'app/app.component.css'],'app/app.component.css','my app', templateUrl:'app/app.component.html', '@Component '這就是它的定義,它與System.js一起工作,在webpack中失敗。 – Bogac
你的代碼是否在github上?在你的webpack中['ts','angular2-template-loader']不應該是['ts -loader','angular2-template-loader'] –