Trying to setup webpack CSS modules with my angular/ionic project. Is it possible to have my CSS module class definitions appended correctly to and external template rather than an inline template?
When I hard code my template into the route it works fine:
var styles = require('./css.css')
module.exports = function(ngModule) {
ngModule.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tab.two', {
url: '/two',
views: {
'module-two': {
template:`<ion-view view-title="Module Two"> <ion-content class="padding moduleTwo"> <h2 class="${styles.title}">Welcome to Module Two</h2> </ion-content> </ion-view>`,
controller: 'TwoCtrl'
}
}
})
})
}
Is there a way though to just require my template into
var styles = require('./css.css')
module.exports = function(ngModule) {
ngModule.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tab.two', {
url: '/two',
views: {
'module-two': {
template:require('./myTemplate.html'),
controller: 'TwoCtrl'
}
}
})
})
}
I figured I might need set my webpack.config up differently but I'm not sure.
var webpack = require('webpack');
var path = require('path');
module.exports = {
entry: './index.js',
output: {
filename: 'bundle.js',
},
module: {
loaders: [
{test: /\.js$/, loader: "ng-annotate!babel", exclude: /node_modules/},
{test: /\.html$/, loader: "raw", exclude: /node_modules/},
{test: /\.json$/, loader: "json", exclude: /node_modules/},
{
test: /\.css$/,
loader: "style!css-loader?modules&localIdentName=[name]__[local]___[hash:base64:5]",
exclude: [
path.resolve(__dirname, 'node_modules')
]
}]
}
};