0
Angular 2 .tsコンポーネントに関連付けられた.lessファイルをコンパイルするためにless-loaderを使用しようとしています。私の人生の間、正しく動作するようにはできません。Webpack Angular 2 less-loaderの設定
module.exports = {
entry: './client/main.ts',
output: {
path: './dist',
filename: 'app.bundle.js'
},
module: {
loaders: [
{test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts'},
{test: /\.html$/,
exclude: /node_modules/,
loader: 'raw'},
{test: /\.css$/,
exclude: /node_modules/,
loader: 'css-loader'},
{test: /\.less$/,
exclude: /node_modules/,
loader: 'raw!less-loader'}
]
},
resolve: {
extensions: ['', '.js', '.ts', '.html', '.css', '.less']
},
plugins: [
new HtmlWebpackPlugin({
template: './client/index.html'
}),
new webpack.DefinePlugin({
app: {
environment: JSON.stringify(process.env.APP_ENVIRONMENT ||
'development')
}
npmで「less-loader」をインストールしました。コンポーネントのスタイルを次のようにロードします。 {Component}を "@ angular/core"からインポートします。
@Component({
selector:'welcome',
template: require('./welcome.component.html'),
styleUrls: require('./welcome.less')
})
export class WelcomeComponent{}
マイフォルダ構造は、ここで
-webpack.config.js
-client/
-welcome/
welcome.component.ts
welcome.less
であるが、完全な誤り
app.bundle.js:13838 Uncaught TypeError: stylesheet.styles.map is not a
function
at DirectiveNormalizer.normalizeStylesheet
(http://localhost:3000/app.bundle.js:13838:46)
at DirectiveNormalizer.normalizeLoadedTemplate
(http://localhost:3000/app.bundle.js:13778:46)
at DirectiveNormalizer.normalizeTemplateSync
(http://localhost:3000/app.bundle.js:13763:24)
at DirectiveNormalizer.normalizeDirective
(http://localhost:3000/app.bundle.js:13739:46)
at RuntimeCompiler._createCompiledTemplate
(http://localhost:3000/app.bundle.js:17139:211)
at http://localhost:3000/app.bundle.js:17077:44
at Array.forEach (native)
at http://localhost:3000/app.bundle.js:17075:51
at Array.forEach (native)
at RuntimeCompiler._compileComponents
(http://localhost:3000/app.bundle.js:17074:46)
あるすべてのヘルプは大、おかげでいただければ幸いです!