Skip to content

Commit

Permalink
refactor: code (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Dec 17, 2019
1 parent 5c51b90 commit 28e1628
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 9 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ options.insert = ${insert};
var content = require(${loaderUtils.stringifyRequest(this, `!!${request}`)});
content = content.__esModule ? content.default : content;
var update = require(${loaderUtils.stringifyRequest(
var api = require(${loaderUtils.stringifyRequest(
this,
`!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}`
)})(content, options);
)});
var update = api(content, options);
${hmrCode}`;
}

Expand Down Expand Up @@ -113,10 +114,11 @@ if (content.locals) {
exports.use = function() {
if (!(refs++)) {
dispose = require(${loaderUtils.stringifyRequest(
var api = require(${loaderUtils.stringifyRequest(
this,
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}`
)})(content, options);
)});
dispose = api(content, options);
}
return exports;
Expand Down Expand Up @@ -180,10 +182,11 @@ var options = ${JSON.stringify(options)}
options.insert = ${insert};
options.singleton = ${isSingleton};
var update = require(${loaderUtils.stringifyRequest(
var api = require(${loaderUtils.stringifyRequest(
this,
`!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}`
)})(content, options);
)});
var update = api(content, options);
if (content.locals) {
module.exports = content.locals;
Expand Down
14 changes: 7 additions & 7 deletions test/manual/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
],
use: [
{
loader: require.resolve('../../dist/index.js'),
loader: require.resolve('../../dist/cjs.js'),
},
{
loader: 'css-loader',
Expand All @@ -44,7 +44,7 @@ module.exports = {
exclude: [/\.lazy\.css$/i, /\.link\.css$/i, /\.lazy\.module\.css$/i],
use: [
{
loader: require.resolve('../../dist/index.js'),
loader: require.resolve('../../dist/cjs.js'),
},
{
loader: 'css-loader',
Expand All @@ -60,7 +60,7 @@ module.exports = {
test: /\.lazy\.css$/i,
use: [
{
loader: require.resolve('../../dist/index.js'),
loader: require.resolve('../../dist/cjs.js'),
options: { injectType: 'lazyStyleTag' },
},
{
Expand All @@ -76,7 +76,7 @@ module.exports = {
test: /\.lazy\.module\.css$/i,
use: [
{
loader: require.resolve('../../dist/index.js'),
loader: require.resolve('../../dist/cjs.js'),
options: { injectType: 'lazyStyleTag' },
},
{
Expand All @@ -94,7 +94,7 @@ module.exports = {
test: /\.link\.css$/i,
use: [
{
loader: require.resolve('../../dist/index.js'),
loader: require.resolve('../../dist/cjs.js'),
options: { injectType: 'linkTag' },
},
{
Expand All @@ -107,7 +107,7 @@ module.exports = {
exclude: /\.lazy\.scss$/i,
use: [
{
loader: require.resolve('../../dist/index.js'),
loader: require.resolve('../../dist/cjs.js'),
},
{
loader: 'css-loader',
Expand All @@ -130,7 +130,7 @@ module.exports = {
test: /\.lazy\.scss$/i,
use: [
{
loader: require.resolve('../../dist/index.js'),
loader: require.resolve('../../dist/cjs.js'),
options: { injectType: 'lazyStyleTag' },
},
{
Expand Down

0 comments on commit 28e1628

Please sign in to comment.