Skip to content

Commit

Permalink
Merge pull request #29 from ansidev/feature/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies, migrate config, rebuild lib
  • Loading branch information
officert authored Jan 23, 2019
2 parents e27e758 + ecb1890 commit 6ddcf8a
Show file tree
Hide file tree
Showing 14 changed files with 6,809 additions and 13,093 deletions.
5 changes: 2 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"presets": [
"es2015",
"stage-2"
["@babel/env", { "modules": false }]
],
"plugins": [
"transform-runtime",
"@babel/transform-runtime",
"add-module-exports"
],
"comments": false
Expand Down
File renamed without changes.
19 changes: 14 additions & 5 deletions build/webpack.base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict'
'use strict';

const options = require('./options');
const autoprefixer = require('autoprefixer');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
resolve: {
Expand All @@ -20,21 +21,29 @@ module.exports = {
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
less: 'vue-style-loader!css-loader!less-loader' // <style lang="less">
},
postcss: [
autoprefixer({
browsers: ['last 2 versions', 'ie > 9', 'Firefox ESR']
})
]
}
},
{
test: /\.less$/,
use: [
'vue-style-loader',
'css-loader',
'less-loader'
]
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
}
},
plugins: [
new VueLoaderPlugin(),
]
};
12 changes: 10 additions & 2 deletions build/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
'use strict';

const merge = require('deep-assign');
const merge = require('webpack-merge');
const webpack = require('webpack');

const options = require('./options');
Expand All @@ -27,4 +27,12 @@ const config = merge(baseConfig, {
}
});

config.module.rules.push({
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
});

module.exports = config;
51 changes: 35 additions & 16 deletions build/webpack.dist.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict'

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require('terser-webpack-plugin');

const merge = require('deep-assign');
const merge = require('webpack-merge');
const webpack = require('webpack');

const options = require('./options');
Expand All @@ -20,15 +21,25 @@ const config = merge(baseConfig, {
path: options.paths.output.main,
libraryTarget: 'umd'
},
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
ecma: 6,
compress: true,
output: {
comments: false,
beautify: false
}
}
}),
]
},
plugins: [
new webpack.BannerPlugin({
banner: options.banner,
raw: true,
entryOnly: true
}),

new ExtractTextPlugin({
filename: options.isProduction ? 'vue2-slideout-panel.min.css' : 'vue2-slideout-panel.css'
})
]
});
Expand All @@ -41,22 +52,30 @@ config.plugins = config.plugins.concat([
new webpack.DefinePlugin({
VERSION: JSON.stringify(options.version)
})
])
]);

if (options.isProduction) {
config.plugins = config.plugins.concat([
config.plugins.push(
// Set the production environment
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),

// Minify with dead-code elimination
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]);
);
}

config.module.rules.push({
test: /\.css$/,
use: [
options.isProduction ? MiniCssExtractPlugin.loader : 'vue-style-loader',
'css-loader'
]
});

config.plugins.push(
new MiniCssExtractPlugin({
filename: options.isProduction ? 'vue2-slideout-panel.min.css' : 'vue2-slideout-panel.css',
disable: !options.isProduction
})
);

module.exports = config;
39 changes: 26 additions & 13 deletions build/webpack.docs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict'

const merge = require('deep-assign');
const merge = require('webpack-merge');
const webpack = require('webpack');

const options = require('./options');
const baseConfig = require('./webpack.base.js');

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require('terser-webpack-plugin');

const config = merge(baseConfig, {
entry: options.paths.resolve('docs-src/index.js'),
Expand All @@ -16,9 +17,23 @@ const config = merge(baseConfig, {
path: options.paths.output.docs
},

optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
ecma: 6,
compress: true,
output: {
comments: false,
beautify: false
}
}
}),
]
},
plugins: [
new ExtractTextPlugin({
filename: 'docs.css'
new MiniCssExtractPlugin({
filename: 'docs.css',
}),

new webpack.LoaderOptionsPlugin({
Expand All @@ -29,21 +44,19 @@ const config = merge(baseConfig, {
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
VERSION: JSON.stringify(options.version)
}),

// Minify with dead-code elimination
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
});


// First item in module.rules array is Vue
config.module.rules[0].options.loaders = {
less: 'vue-style-loader!css-loader!less-loader'
};
config.module.rules.push({
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
});

module.exports = config;
Loading

0 comments on commit 6ddcf8a

Please sign in to comment.