|
|
|
@ -2,37 +2,43 @@ var HtmlWebpackPlugin = require('html-webpack-plugin'); |
|
|
|
var pkg = require('./package.json'); |
|
|
|
var webpack = require('webpack'); |
|
|
|
var fs = require('fs'); |
|
|
|
var plugins = []; |
|
|
|
|
|
|
|
if (process.env.WEBPACK_ENV !== 'dev') { |
|
|
|
plugins = [ |
|
|
|
new webpack.optimize.ModuleConcatenationPlugin(), |
|
|
|
new webpack.optimize.UglifyJsPlugin({ minimize:true, compressor: {warnings:false}}), |
|
|
|
new webpack.BannerPlugin(pkg.name + ' - ' + pkg.version), |
|
|
|
] |
|
|
|
} else { |
|
|
|
var index = 'index.html'; |
|
|
|
var indexDev = '_' + index; |
|
|
|
plugins.push(new HtmlWebpackPlugin({ |
|
|
|
template: fs.existsSync(indexDev) ? indexDev : index |
|
|
|
})); |
|
|
|
} |
|
|
|
module.exports = env => { |
|
|
|
var plugins = []; |
|
|
|
|
|
|
|
var output = { |
|
|
|
filename: './dist/grapes.min.js', |
|
|
|
library: 'grapesjs', |
|
|
|
libraryTarget: 'umd', |
|
|
|
}; |
|
|
|
|
|
|
|
plugins.push(new webpack.ProvidePlugin({ |
|
|
|
_: 'underscore', |
|
|
|
Backbone: 'backbone' |
|
|
|
})); |
|
|
|
|
|
|
|
module.exports = { |
|
|
|
entry: './src', |
|
|
|
output: { |
|
|
|
filename: './dist/grapes.min.js', |
|
|
|
library: 'grapesjs', |
|
|
|
libraryTarget: 'umd', |
|
|
|
}, |
|
|
|
plugins: plugins, |
|
|
|
module: { |
|
|
|
loaders: [{ |
|
|
|
if (env.prod || env.production) { |
|
|
|
plugins = [ |
|
|
|
new webpack.optimize.ModuleConcatenationPlugin(), |
|
|
|
new webpack.optimize.UglifyJsPlugin({ minimize:true, compressor: {warnings:false}}), |
|
|
|
new webpack.BannerPlugin(pkg.name + ' - ' + pkg.version), |
|
|
|
]; |
|
|
|
output.filename = './dist/grapes.min.js'; |
|
|
|
} else { |
|
|
|
var index = 'index.html'; |
|
|
|
var indexDev = '_' + index; |
|
|
|
plugins.push(new HtmlWebpackPlugin({ |
|
|
|
template: fs.existsSync(indexDev) ? indexDev : index |
|
|
|
})); |
|
|
|
output.filename = './dist/grapes.js'; |
|
|
|
} |
|
|
|
|
|
|
|
plugins.push(new webpack.ProvidePlugin({ |
|
|
|
_: 'underscore', |
|
|
|
Backbone: 'backbone' |
|
|
|
})); |
|
|
|
|
|
|
|
return { |
|
|
|
entry: './src', |
|
|
|
output: output, |
|
|
|
plugins: plugins, |
|
|
|
module: { |
|
|
|
loaders: [{ |
|
|
|
test: /grapesjs\/index\.js$/, |
|
|
|
loader: 'string-replace-loader', |
|
|
|
query: { |
|
|
|
@ -44,12 +50,13 @@ module.exports = { |
|
|
|
loader: 'babel-loader', |
|
|
|
include: /src/, |
|
|
|
exclude: /node_modules/ |
|
|
|
}], |
|
|
|
}, |
|
|
|
resolve: { |
|
|
|
modules: ['src', 'node_modules'], |
|
|
|
alias: { |
|
|
|
jquery: 'cash-dom' |
|
|
|
}], |
|
|
|
}, |
|
|
|
resolve: { |
|
|
|
modules: ['src', 'node_modules'], |
|
|
|
alias: { |
|
|
|
jquery: 'cash-dom' |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}; |
|
|
|
} |
|
|
|
|