...
|
...
|
@@ -50,30 +50,30 @@ const dist = { |
|
|
*/
|
|
|
const postcssPlugin = (et) => {
|
|
|
let sprites = {
|
|
|
spritesmith: {
|
|
|
padding: 8
|
|
|
},
|
|
|
filterBy(file) {
|
|
|
// base64 的图片没有 url 过滤掉
|
|
|
if (file.url) {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
|
return Promise.reject();
|
|
|
},
|
|
|
groupBy(file) {
|
|
|
let group = file.url.split('/')[1];
|
|
|
let entry = path.basename(file.styleFilePath);
|
|
|
|
|
|
file.retina = true;
|
|
|
file.radio = 2;
|
|
|
spritesmith: {
|
|
|
padding: 8
|
|
|
},
|
|
|
filterBy(file) {
|
|
|
// base64 的图片没有 url 过滤掉
|
|
|
if (file.url) {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
|
return Promise.reject();
|
|
|
},
|
|
|
groupBy(file) {
|
|
|
let group = file.url.split('/')[1];
|
|
|
let entry = path.basename(file.styleFilePath);
|
|
|
|
|
|
if (group) {
|
|
|
group = entry + '.' + group;
|
|
|
}
|
|
|
file.retina = true;
|
|
|
file.radio = 2;
|
|
|
|
|
|
return group ? Promise.resolve(group) : Promise.reject('yoho');
|
|
|
if (group) {
|
|
|
group = entry + '.' + group;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
return group ? Promise.resolve(group) : Promise.reject('yoho');
|
|
|
}
|
|
|
},
|
|
|
assets,
|
|
|
plugins;
|
|
|
|
...
|
...
|
@@ -228,8 +228,10 @@ gulp.task('webpack-dev-server', () => { |
|
|
devConfig.output.publicPath = 'http://localhost:5001/';
|
|
|
|
|
|
// 开发环境插件
|
|
|
devConfig.plugins[0] = new ExtractTextPlugin('bundle/[name].css');
|
|
|
devConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
|
|
|
devConfig.plugins.push(
|
|
|
new ExtractTextPlugin('bundle/[name].css'),
|
|
|
new webpack.HotModuleReplacementPlugin()
|
|
|
);
|
|
|
|
|
|
devConfig.entry.libs.unshift(`webpack-dev-server/client?${devConfig.output.publicPath}`, 'webpack/hot/dev-server');
|
|
|
|
...
|
...
|
@@ -281,13 +283,16 @@ gulp.task('webpack', ['assets'], (done) => { |
|
|
proConfig.output.path = dist.js;
|
|
|
|
|
|
// 生产环境插件
|
|
|
proConfig.plugins.push(new webpack.DefinePlugin({
|
|
|
'process.env': {
|
|
|
NODE_ENV: '"production"'
|
|
|
}
|
|
|
}), new UglifyJsParallelPlugin({
|
|
|
workers: os.cpus().length
|
|
|
}));
|
|
|
proConfig.plugins.push(
|
|
|
new webpack.DefinePlugin({
|
|
|
'process.env': {
|
|
|
NODE_ENV: '"production"'
|
|
|
}
|
|
|
}),
|
|
|
new UglifyJsParallelPlugin({
|
|
|
workers: os.cpus().length
|
|
|
})
|
|
|
);
|
|
|
|
|
|
webpack(proConfig, (err, stats) => {
|
|
|
if (err) {
|
...
|
...
|
|