Skip to content

Commit 5386656

Browse files
authored
Merge pull request #2 from jsilvax/dev-branch
Merged dev-branch into master
2 parents 37aa044 + 322293c commit 5386656

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+7989
-499
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ test/fixtures/**/dir
55
.coveralls.yml
66
*.log
77
/dist
8-
.vscode
8+
.vscode/
9+
.yarn-error.log

__tests__/css-entry-array.test.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const webpack = require('webpack');
2+
const path = require('path');
3+
const rimraf = require('rimraf');
4+
const options = require('./fixtures/css-array-entry/webpack.config.js');
5+
const optionsSass = require('./fixtures/css-array-entry/webpack.config.sass');
6+
const optionsLess = require('./fixtures/css-array-entry/webpack.config.less');
7+
const dirPath = path.join(__dirname, './fixtures/css-array-entry/dir');
8+
const fileShouldNotExist = require('./utils/file-should-not-exist.js');
9+
10+
describe('Array of CSS Dependencies as Entry', () => {
11+
beforeEach(done => {
12+
rimraf(dirPath, () => {
13+
done();
14+
});
15+
});
16+
17+
it('JS entry should not exist', done => {
18+
webpack(options, () => {
19+
fileShouldNotExist(dirPath, '/a.js');
20+
done();
21+
});
22+
});
23+
24+
it('JS entry source map should not exist', done => {
25+
const optionSourceMap = Object.assign({}, options);
26+
optionSourceMap.devtool = 'source-map';
27+
28+
webpack(optionSourceMap, () => {
29+
fileShouldNotExist(dirPath, '/a.js.map');
30+
done();
31+
});
32+
});
33+
34+
it('JS entry should not exist w/ sass', done => {
35+
webpack(optionsSass, () => {
36+
fileShouldNotExist(dirPath, '/s.js');
37+
done();
38+
});
39+
});
40+
41+
it('JS entry source map should not exist w/ sass', done => {
42+
const optionSourceMap = Object.assign({}, options);
43+
optionSourceMap.devtool = 'source-map';
44+
45+
webpack(optionSourceMap, () => {
46+
fileShouldNotExist(dirPath, '/s.js.map');
47+
done();
48+
});
49+
});
50+
51+
it('JS entry should not exist w/ less', done => {
52+
webpack(optionsLess, () => {
53+
fileShouldNotExist(dirPath, '/l.js');
54+
done();
55+
});
56+
});
57+
58+
it('JS entry source map should not exist w/ less', done => {
59+
const optionSourceMap = Object.assign({}, optionsLess);
60+
optionSourceMap.devtool = 'source-map';
61+
62+
webpack(optionSourceMap, () => {
63+
fileShouldNotExist(dirPath, '/l.js.map');
64+
done();
65+
});
66+
});
67+
});

__tests__/fixtures/css-array-entry/dir/l.css

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/fixtures/css-array-entry/dir/l.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@nice-blue: #5B83AD;
2+
@light-blue: @nice-blue + #111;
3+
4+
#header {
5+
color: @light-blue;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$font-stack: Helvetica, sans-serif
2+
$primary-color: #333
3+
4+
body
5+
font: 100% $font-stack
6+
color: $primary-color
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@nice-yellow: yellow;
2+
3+
.duck {
4+
color: @nice-yellow;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$font-stack: Helvetica, sans-serif;
2+
$primary-color: #333;
3+
4+
body {
5+
font: 100% $font-stack;
6+
color: $primary-color;
7+
}
8+
9+
.green {
10+
color : green;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
2+
const OmitJSforCSSPlugin = require('../../../src/index.js');
3+
const path = require('path');
4+
5+
module.exports = {
6+
entry: {
7+
l: [path.join(__dirname, 'one.less'), path.join(__dirname, 'two.less')]
8+
},
9+
output: {
10+
filename: '[name].js',
11+
path: path.join(__dirname, '/dir')
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.(less)$/,
17+
use: [
18+
MiniCssExtractPlugin.loader,
19+
'css-loader',
20+
'less-loader'
21+
]
22+
}
23+
]
24+
},
25+
mode: 'development',
26+
plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()],
27+
stats: 'none'
28+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
2+
const OmitJSforCSSPlugin = require('../../../src/index.js');
3+
const path = require('path');
4+
5+
module.exports = {
6+
entry: {
7+
s: [path.join(__dirname, 'two.scss'), path.join(__dirname, 'three.sass')]
8+
},
9+
output: {
10+
filename: '[name].js',
11+
path: path.join(__dirname, '/dir')
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.(scss|sass)$/,
17+
use: [
18+
MiniCssExtractPlugin.loader,
19+
'css-loader',
20+
'sass-loader'
21+
]
22+
}
23+
]
24+
},
25+
plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()],
26+
mode : 'development',
27+
devtool: 'source-map',
28+
stats: 'none'
29+
};

__tests__/fixtures/js-file-entry/dir/s.css

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/fixtures/js-file-entry/dir/s.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@nice-blue: #5B83AD;
2+
@light-blue: @nice-blue + #111;
3+
4+
#header {
5+
color: @light-blue;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('./one.less');
2+
require('./two.less');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('./two.scss');
2+
require('./three.sass');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$font-stack: Helvetica, sans-serif
2+
$primary-color: #333
3+
4+
body
5+
font: 100% $font-stack
6+
color: $primary-color
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@nice-yellow: yellow;
2+
3+
.duck {
4+
color: @nice-yellow;
5+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
$font-stack: Helvetica, sans-serif;
2+
$primary-color: #333;
3+
4+
body {
5+
font: 100% $font-stack;
6+
color: $primary-color;
7+
}
8+
9+
.green {
10+
color : green;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
2+
const OmitJSforCSSPlugin = require('../../../src/index.js');
3+
const path = require('path');
4+
5+
module.exports = {
6+
entry: {
7+
l: path.join(__dirname, 'styles-less.js')
8+
},
9+
output: {
10+
filename: '[name].js',
11+
path: path.join(__dirname, '/dir')
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.(less)$/,
17+
use: [
18+
MiniCssExtractPlugin.loader,
19+
'css-loader',
20+
'less-loader'
21+
]
22+
}
23+
]
24+
},
25+
mode: 'development',
26+
plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()],
27+
stats: 'none'
28+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
2+
const OmitJSforCSSPlugin = require('../../../src/index.js');
3+
const path = require('path');
4+
5+
module.exports = {
6+
entry: {
7+
s: path.join(__dirname, 'styles-sass.js')
8+
},
9+
output: {
10+
filename: '[name].js',
11+
path: path.join(__dirname, '/dir')
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.(scss|sass)$/,
17+
use: [
18+
MiniCssExtractPlugin.loader,
19+
'css-loader',
20+
'sass-loader'
21+
]
22+
}
23+
]
24+
},
25+
plugins: [new MiniCssExtractPlugin({ filename: '[name].css' }), new OmitJSforCSSPlugin()],
26+
mode : 'development',
27+
devtool: 'source-map',
28+
stats: 'none'
29+
};

__tests__/fixtures/options/preview/dir/b.css

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/fixtures/options/preview/dir/b.css.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)