0
我正在嘗試使用less-loader來編譯與我的Angular 2 .ts組件相關的.less文件,並且對於我的生活我無法讓它正常工作。Webpack Angular 2 less-loader config
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 '少裝載機'。我將我的樣式加載到我的組件中,如下所示 從「@ angular/core」導入{Component};
@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)
任何幫助將不勝感激,謝謝!