@@ -3,12 +3,14 @@ const path = require('path')
3
3
const webpack = require ( 'webpack' )
4
4
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
5
5
const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' )
6
+ const StylablePlugin = require ( 'stylable-integration/webpack-plugin' )
6
7
7
8
const production = process . env . NODE_ENV === 'production'
8
9
const settings = require ( './scripts/settings.js' )
9
10
const devServer = settings . devServer
10
11
const basePath = path . join ( __dirname )
11
12
const cssModulesPath = path . resolve ( __dirname , '05-react-css-modules' )
13
+ const stylablePath = path . resolve ( __dirname , '09-stylable' )
12
14
13
15
let cssModulesLoaders = [
14
16
'style-loader' ,
@@ -55,8 +57,8 @@ const webpackEntries = projectPaths.reduce((allEntreis, currPath) => {
55
57
56
58
let htmlPlugins = Object . keys ( webpackEntries ) . reduce ( ( acc , cur , idx , arr ) => {
57
59
acc . push ( new HtmlWebpackPlugin ( {
58
- inject : true ,
59
- template : cur . indexOf ( 'button' ) !== - 1 ? 'templates/server.ejs' : 'templates/plain.ejs' ,
60
+ inject : true ,
61
+ template : cur . indexOf ( 'button' ) !== - 1 ? 'templates/server.ejs' : 'templates/plain.ejs' ,
60
62
title : cur ,
61
63
filename : cur + '/index.html' ,
62
64
chunks : [ cur ]
@@ -67,7 +69,8 @@ let htmlPlugins = Object.keys(webpackEntries).reduce((acc, cur, idx, arr) => {
67
69
const webpackPlugins = [
68
70
...htmlPlugins ,
69
71
new webpack . HotModuleReplacementPlugin ( ) ,
70
- new webpack . NoEmitOnErrorsPlugin ( )
72
+ new webpack . NoEmitOnErrorsPlugin ( ) ,
73
+ new StylablePlugin ( { injectBundleCss : true } )
71
74
]
72
75
73
76
if ( production ) {
@@ -95,26 +98,40 @@ module.exports = {
95
98
{
96
99
test : / \. j s $ / ,
97
100
exclude : / n o d e _ m o d u l e s / ,
98
- use : [
99
- 'react-hot-loader/webpack' ,
100
- 'babel-loader?cacheDirectory=true'
101
+ use : [
102
+ 'react-hot-loader/webpack' ,
103
+ 'babel-loader?cacheDirectory=true'
101
104
]
102
105
} ,
103
106
{
104
107
test : / \. s ? c s s $ / ,
105
108
include : [ cssModulesPath ] ,
106
109
use : cssModulesLoaders
107
110
} ,
111
+ StylablePlugin . rule ( ) ,
112
+ {
113
+ test : / \. ( p n g | j p g | g i f | s v g ) $ / ,
114
+ include : [ stylablePath ] ,
115
+ use : [
116
+ {
117
+ loader : 'url-loader' ,
118
+ options : {
119
+ limit : 8192
120
+ }
121
+ }
122
+ ]
123
+ } ,
108
124
{
109
125
test : / \. c s s $ / ,
110
- use : [
126
+ exclude : [ stylablePath , cssModulesPath ] ,
127
+ use : [
111
128
'style-loader' ,
112
- 'css-loader'
129
+ 'css-loader'
113
130
] ,
114
- exclude : [ cssModulesPath ] ,
115
131
} ,
116
132
{
117
133
test : / \. ( j p e ? g | p n g | g i f | s v g ) $ / i,
134
+ exclude : [ stylablePath ] ,
118
135
use : [ 'file-loader?name=[path][name].[hash].[ext]' ]
119
136
} ,
120
137
{
0 commit comments