Skip to content

Commit 49936bd

Browse files
committed
feat: 本地环境下不使用 extract 插件
1 parent b452015 commit 49936bd

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

lib/models/Config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
2525
var normalize = require('../utils/path').normalize;
2626

2727
var Config = function () {
28-
function Config(cwd, configFile) {
28+
function Config(cwd, configFile, env) {
2929
(0, _classCallCheck3.default)(this, Config);
3030

3131
var dir = normalize(cwd).split('/');
@@ -72,7 +72,7 @@ var Config = function () {
7272
loader: require.resolve('html-loader')
7373
}, {
7474
test: /\.css$/,
75-
loader: ExtractTextPlugin.extract(require.resolve('style-loader'), require.resolve('css-loader'))
75+
loader: env === 'local' ? 'style!css' : ExtractTextPlugin.extract(require.resolve('style-loader'), require.resolve('css-loader'))
7676
}],
7777
postLoaders: []
7878
},

lib/models/Project.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ var Project = function () {
5656

5757
this.cwd = cwd;
5858
this.configFile = globby.sync(['ykit.*.js', 'ykit.js'], { cwd: cwd })[0] || '';
59-
6059
this.plugins = [];
61-
this.config = new Config(cwd, this.configFile);
60+
this.config = new Config(cwd, this.configFile, this._getCurrentEnv());
6261
this.commands = Manager.getCommands();
6362
this.middlewares = [];
6463
this.beforePackCallbacks = [];
@@ -408,7 +407,7 @@ var Project = function () {
408407
var isExtractTextPluginExists = config.plugins.some(function (plugin) {
409408
return plugin instanceof ExtractTextPlugin;
410409
});
411-
if (!isExtractTextPluginExists) {
410+
if (!isExtractTextPluginExists && this._getCurrentEnv() !== 'local') {
412411
config.plugins.push(new ExtractTextPlugin(config.output.filename.replace('[ext]', '.css')));
413412
}
414413
}

src/models/Config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
66
const normalize = require('../utils/path').normalize;
77

88
class Config {
9-
constructor(cwd, configFile) {
9+
constructor(cwd, configFile, env) {
1010
const dir = normalize(cwd).split('/');
1111
const projectDir = dir[dir.length - 1];
1212

@@ -51,7 +51,7 @@ class Config {
5151
loader: require.resolve('html-loader')
5252
}, {
5353
test: /\.css$/,
54-
loader: ExtractTextPlugin.extract(
54+
loader: env === 'local' ? 'style!css' : ExtractTextPlugin.extract(
5555
require.resolve('style-loader'),
5656
require.resolve('css-loader')
5757
)

src/models/Project.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ class Project {
2424
constructor(cwd) {
2525
this.cwd = cwd;
2626
this.configFile = globby.sync(['ykit.*.js', 'ykit.js'], { cwd: cwd })[0] || '';
27-
2827
this.plugins = [];
29-
this.config = new Config(cwd, this.configFile);
28+
this.config = new Config(cwd, this.configFile, this._getCurrentEnv());
3029
this.commands = Manager.getCommands();
3130
this.middlewares = [];
3231
this.beforePackCallbacks = [];
@@ -390,7 +389,7 @@ class Project {
390389
const isExtractTextPluginExists = config.plugins.some((plugin) => {
391390
return plugin instanceof ExtractTextPlugin;
392391
});
393-
if(!isExtractTextPluginExists) {
392+
if(!isExtractTextPluginExists && this._getCurrentEnv() !== 'local') {
394393
config.plugins.push(new ExtractTextPlugin(config.output.filename.replace('[ext]', '.css')));
395394
}
396395
}

0 commit comments

Comments
 (0)