Skip to content

Commit 8a593a6

Browse files
Merge pull request #14 from metalabdesign/move-raw-source-out
Further updates for `webpack@2`.
2 parents a697240 + 63f98d2 commit 8a593a6

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

.travis.yml

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,20 @@
11
sudo: false
22
language: node_js
3+
node_js:
4+
- 4
5+
- 5
6+
- 6
7+
env:
8+
- USE_WEBPACK2=false
9+
- USE_WEBPACK2=true
310
matrix:
4-
include:
5-
# Run tests in Node.js 0.12
6-
- node_js: '0.12'
7-
8-
# Run tests in Node.js 4.x
9-
- node_js: '4'
10-
addons:
11-
apt:
12-
sources:
13-
- ubuntu-toolchain-r-test
14-
packages:
15-
- gcc-4.8
16-
- g++-4.8
17-
18-
# Run tests in Node.js 5.x
19-
- node_js: '5'
20-
addons:
21-
apt:
22-
sources:
23-
- ubuntu-toolchain-r-test
24-
packages:
25-
- gcc-4.8
26-
- g++-4.8
11+
exclude:
12+
# TODO: Fix barf on peer dependencies with npm@2.
13+
- env: USE_WEBPACK2=true
14+
node_js: 4
2715

2816
before_install:
29-
# Use GCC 4.8 if it's available
30-
- 'if [ ! `which gcc-4.8` == "" ]; then export CXX=g++-4.8 && export CC=gcc-4.8; fi'
17+
- 'if [ "${USE_WEBPACK2}" == "true" ]; then npm install --save-dev webpack@2.1.0-beta.19 extract-text-webpack-plugin@2.0.0-beta.4; fi'
3118

3219
after_script:
3320
- npm install coveralls

example/basic/webpack.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ module.exports = {
1212
module: {
1313
loaders: [{
1414
test: /\.css$/,
15-
loader: ExtractTextPlugin.extract('style-loader', 'css-loader'),
15+
loader: ExtractTextPlugin.extract.length !== 1 ?
16+
ExtractTextPlugin.extract('style-loader', 'css-loader') :
17+
ExtractTextPlugin.extract({
18+
fallbackLoader: 'style-loader',
19+
loader: 'css-loader',
20+
}),
1621
}],
1722
},
1823
devtool: 'source-map',

src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import postcss from 'postcss';
22
import chunk from './chunk';
3-
import {SourceMapSource} from 'webpack-sources';
4-
import RawSource from 'webpack/lib/RawSource';
3+
import {SourceMapSource, RawSource} from 'webpack-sources';
54
import {interpolateName} from 'loader-utils';
65

76
/**

test/spec/index.spec.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ import {expect} from 'chai';
88
const basic = path.join('.', 'basic', 'index.js');
99
const less = path.join('.', 'less', 'index.js');
1010

11+
const extract = ExtractTextPlugin.extract.length !== 1 ?
12+
(a, b) => ExtractTextPlugin.extract(a, b) :
13+
(fallbackLoader, loader) => loader ? ExtractTextPlugin.extract({
14+
fallbackLoader,
15+
loader,
16+
}) : ExtractTextPlugin.extract({
17+
loader: fallbackLoader,
18+
});
19+
1120
const config = (options, entry = basic, extra) => {
1221
return {
1322
entry: path.join(__dirname, '..', '..', 'example', entry),
@@ -20,13 +29,13 @@ const config = (options, entry = basic, extra) => {
2029
module: {
2130
loaders: [{
2231
test: /\.css$/,
23-
loader: ExtractTextPlugin.extract(
32+
loader: extract(
2433
'style-loader',
2534
'css-loader?sourceMap'
2635
),
2736
}, {
2837
test: /\.less$/,
29-
loader: ExtractTextPlugin.extract(
38+
loader: extract(
3039
'css?-url&-autoprefixer&sourceMap!less?sourceMap'
3140
),
3241
}],

0 commit comments

Comments
 (0)