Skip to content

Commit

Permalink
refactor: debug 'release' script done
Browse files Browse the repository at this point in the history
  • Loading branch information
linx4200 committed Jul 26, 2017
1 parent dd9b48a commit 63299f6
Show file tree
Hide file tree
Showing 6 changed files with 5,288 additions and 4,867 deletions.
68 changes: 10 additions & 58 deletions build/webpack.release.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var vue = require('vue-loader')
var path = require('path')
var webpack = require("webpack")
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var projectRoot = path.resolve(__dirname, '../')
var cssLoader = ExtractTextPlugin.extract('style-loader', 'css-loader')
var vueLoaderConfig = require('./vue-loader.conf')

function resolve (dir) {
return path.join(__dirname, '..', dir)
}

module.exports = {
entry: {
Expand All @@ -15,66 +15,18 @@ module.exports = {
libraryTarget: 'umd'
},
module: {
preLoaders: [
rules: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
loader: 'babel-loader',
include: [resolve('src')],
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
// excluding some local linked packages.
// for normal use cases only node_modules is needed.
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.css$/,
loader: cssLoader
},
{
test: /\.styl$/,
loader: ExtractTextPlugin.extract('style-loader','css-loader!stylus-loader')
}
]
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
}
}

if (process.env.NODE_ENV === 'production') {

delete module.exports.devtool
module.exports.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
// new ExtractTextPlugin('build.css')
]
}
9 changes: 6 additions & 3 deletions build/webpack.release.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ var webpack = require('webpack')

config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')

delete config.devtool

config.plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
new webpack.optimize.OccurrenceOrderPlugin()
]

module.exports = config
Loading

0 comments on commit 63299f6

Please sign in to comment.