2017-02-01 112 views
0

這是我的stats file進行分析。 我使用的是最新版本的prestashop(1.7),我想用build生成放在_dev上的webpack腳本,這個問題是一個非常緩慢的編譯和監視任務。Prestashop 1.7 webpack很慢

我用的WebPack運行:

npm run watch 

結果:

Version: webpack 1.14.0 
Time: 12092ms 

如何提高性能?

+0

編譯是否僅在第一次或每次更改文件時都需要12s? –

+0

我看到很多開發者抱怨這個,編譯需要10到30秒。每次需要時,您都不應該使用'watch',而只使用'build'。 –

+0

是的,每次這需要+ -10s @StefanDragnev – user3501587

回答

0
I found same problem my webpack.config file is 

var webpack = require('webpack'); 
var path = require('path'); 
var ExtractTextPlugin = require("extract-text-webpack-plugin"); 

var plugins = []; 

var production = false; 

if (production) { 
    plugins.push(
    new webpack.optimize.UglifyJsPlugin({ 
     compress: { 
     warnings: false 
     } 
    }) 
); 
} 

plugins.push(
    new ExtractTextPlugin(
    path.join(
     '..', 'css', 'theme.css' 
    ) 
) 
); 

module.exports = { 
    entry: [ 
    './js/theme.js' 
    ], 
    output: { 
    path: '../assets/js', 
    filename: 'theme.js' 
    }, 
    module: { 
    loaders: [{ 
     test: /\.js$/, 
     exclude: /node_modules/, 
     loaders: ['babel-loader'] 
    }, { 
     test: /\.scss$/, 
     loader: ExtractTextPlugin.extract(
     "style", 
     "css?sourceMap!postcss!sass?sourceMap" 
    ) 
    }, { 
     test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/, 
     loader: 'file-loader?name=../css/[hash].[ext]' 
    }, { 
     test: /\.css$/, 
     loader: "style-loader!css-loader!postcss-loader" 
    }] 
    }, 
    postcss: function() { 
    return [require('postcss-flexibility')]; 
    }, 
    externals: { 
    prestashop: 'prestashop' 
    }, 
    devtool: 'source-map', 
    plugins: plugins, 
    resolve: { 
    extensions: ['', '.js', '.scss'] 
    } 
};