Skip to content
This repository was archived by the owner on Dec 30, 2020. It is now read-only.

Commit af426b4

Browse files
committed
Fix to allow component styleUrls with webpack without using require inside component.
1 parent 4b1297a commit af426b4

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"json-loader": "0.5.4",
3030
"raw-loader": "0.5.1",
3131
"style-loader": "0.13.1",
32+
"to-string-loader": "1.1.5",
3233
"typescript": "2.0.2",
3334
"url-loader": "0.5.7",
3435
"webpack": "2.1.0-beta.22",

src/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var IsDev = process.argv.indexOf('--env.prod') < 0;
22
var Path = require('path');
33
var Webpack = require('webpack');
4+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
45
var ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
56

67
module.exports = {
@@ -15,6 +16,7 @@ module.exports = {
1516
publicPath: '/dist/'
1617
},
1718
plugins: [
19+
new ExtractTextPlugin({ filename: '[name].css' }),
1820
new ForkCheckerPlugin(),
1921
new Webpack.DllReferencePlugin({
2022
context: __dirname,
@@ -28,7 +30,7 @@ module.exports = {
2830
loaders: [
2931
{ test: /\.ts$/, exclude: [/\.(spec|e2e)\.ts$/], loaders: ['awesome-typescript', 'angular2-template'] },
3032
{ test: /\.html$/, loader: 'html' },
31-
{ test: /\.css/, loader: 'style!css' },
33+
{ test: /\.css$/, loader: [ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader' }), 'to-string-loader', 'css-loader'] },
3234
{ test: /\.svg$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml' },
3335
{ test: /\.(jpeg|jpg|gif|png|json)$/, loaders: ["file-loader?name=[name]-[hash:12].[ext]"] }
3436
]

src/webpack.config.vendor.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
var IsDev = process.argv.indexOf('--env.prod') < 0;
22
var Path = require('path');
33
var Webpack = require('webpack');
4-
var ExtractTextPlugin = require('extract-text-webpack-plugin');
5-
var ExtractCss = new ExtractTextPlugin('vendor.css');
64

75
module.exports = {
86
resolve: {
97
extensions: ['', '.js']
108
},
119
module: {
1210
loaders: [
13-
{ test: /\.css/, loader: ExtractCss.extract(['css']) },
1411
{ test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/, loader: 'url?limit=100000&name=[name].[ext]' },
1512
{ test: /\.json$/, loader: 'json-loader' }
1613
]
@@ -24,7 +21,7 @@ module.exports = {
2421
'@angular/forms',
2522
'@angular/platform-browser',
2623
'@angular/platform-browser-dynamic',
27-
'@angular/router',
24+
'@angular/router'
2825
]
2926
},
3027
output: {
@@ -33,7 +30,6 @@ module.exports = {
3330
library: '[name]_[hash]'
3431
},
3532
plugins: [
36-
ExtractCss,
3733
new Webpack.optimize.OccurrenceOrderPlugin(),
3834
new Webpack.DllPlugin({
3935
path: Path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),

0 commit comments

Comments
 (0)