mirror of https://github.com/artf/grapesjs.git
6 changed files with 64 additions and 62 deletions
File diff suppressed because one or more lines are too long
@ -1,55 +1,56 @@ |
|||
var HtmlWebpackPlugin = require('html-webpack-plugin'); |
|||
var pkg = require('./package.json'); |
|||
var webpack = require('webpack'); |
|||
var fs = require('fs'); |
|||
var plugins = []; |
|||
const HtmlWebpackPlugin = require('html-webpack-plugin'); |
|||
const pkg = require('./package.json'); |
|||
const webpack = require('webpack'); |
|||
const fs = require('fs'); |
|||
let 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 = {}) => { |
|||
if (env.prod) { |
|||
plugins = [ |
|||
new webpack.optimize.ModuleConcatenationPlugin(), |
|||
new webpack.optimize.UglifyJsPlugin({ minimize:true, compressor: {warnings:false}}), |
|||
new webpack.BannerPlugin(`${pkg.name} - ${pkg.version}`), |
|||
] |
|||
} else { |
|||
const index = 'index.html'; |
|||
const indexDev = `_${index}`; |
|||
plugins.push(new HtmlWebpackPlugin({ |
|||
template: fs.existsSync(indexDev) ? indexDev : index |
|||
})); |
|||
} |
|||
|
|||
plugins.push(new webpack.ProvidePlugin({ |
|||
_: 'underscore', |
|||
Backbone: 'backbone' |
|||
})); |
|||
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: [{ |
|||
test: /grapesjs\/index\.js$/, |
|||
loader: 'string-replace-loader', |
|||
query: { |
|||
search: '<# VERSION #>', |
|||
replace: pkg.version |
|||
} |
|||
},{ |
|||
test: /\.js$/, |
|||
loader: 'babel-loader', |
|||
include: /src/, |
|||
exclude: /node_modules/ |
|||
}], |
|||
}, |
|||
resolve: { |
|||
modules: ['src', 'node_modules'], |
|||
alias: { |
|||
jquery: 'cash-dom' |
|||
} |
|||
}, |
|||
return { |
|||
entry: './src', |
|||
output: { |
|||
filename: './dist/grapes.min.js', |
|||
library: 'grapesjs', |
|||
libraryTarget: 'umd', |
|||
}, |
|||
plugins: plugins, |
|||
module: { |
|||
loaders: [{ |
|||
test: /grapesjs\/index\.js$/, |
|||
loader: 'string-replace-loader', |
|||
query: { |
|||
search: '<# VERSION #>', |
|||
replace: pkg.version |
|||
} |
|||
},{ |
|||
test: /\.js$/, |
|||
loader: 'babel-loader', |
|||
include: /src/ |
|||
}], |
|||
}, |
|||
resolve: { |
|||
modules: ['src', 'node_modules'], |
|||
alias: { |
|||
jquery: 'cash-dom' |
|||
} |
|||
}, |
|||
}; |
|||
} |
|||
|
|||
Loading…
Reference in new issue