webpack config

This commit is contained in:
cookfront
2017-03-24 15:36:55 +08:00
parent b39b4547a8
commit bb85b3416c
14 changed files with 72 additions and 46 deletions
+24
View File
@@ -1,3 +1,5 @@
var webpack = require('webpack');
var getPostcssPlugin = require('./utils/postcss_pipe');
var config = require('./webpack.config.js');
config.entry = {
@@ -14,6 +16,28 @@ config.externals = {
vue: 'vue'
};
config.plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
options: {
postcss: getPostcssPlugin,
babel: {
presets: ['es2015'],
plugins: ['transform-runtime', 'transform-vue-jsx']
},
vue: {
autoprefixer: false,
preserveWhitespace: false,
postcss: getPostcssPlugin
}
}
})
];
delete config.devtool;
module.exports = config;
+9 -10
View File
@@ -1,20 +1,19 @@
var config = require('./webpack.build.js');
var webpack = require('webpack');
var getPostcssPlugin = require('./utils/postcss_pipe');
var config = require('./webpack.config.js');
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js');
config.plugins = [
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
config.plugins = config.plugins.concat([
new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: {
drop_console: true,
warnings: false
}
},
output: {
comments: false
},
sourceMap: false
})
];
]);
module.exports = config;
+1 -1
View File
@@ -1,6 +1,6 @@
var path = require('path');
var Components = require('../components.json');
var config = require('./webpack.config.js');
var config = require('./webpack.build.js');
delete config.devtool;
+31 -5
View File
@@ -8,6 +8,14 @@ var version = require('../package.json').version;
var getPoastcssPlugin = require('./utils/postcss_pipe');
var ProgressBarPlugin = require('progress-bar-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var StyleExtractPlugin;
if (process.env.NODE_ENV === 'production') {
StyleExtractPlugin = new ExtractTextPlugin('[name].[hash:8].css');
} else {
StyleExtractPlugin = new ExtractTextPlugin('[name].css');
}
function convert(str) {
str = str.replace(/(&#x)(\w{4});/gi, function($0) {
@@ -26,12 +34,12 @@ function wrap(render) {
module.exports = {
entry: {
'zanui-docs': './docs/index.js',
'zanui-examples': './docs/examples.js'
'docs': './docs/index.js',
'examples': './docs/examples.js'
},
output: {
path: path.join(__dirname, '../docs/dist'),
publicPath: '/vue/docs/dist/',
publicPath: '/',
filename: '[name].js'
},
resolve: {
@@ -88,8 +96,20 @@ module.exports = {
},
devtool: 'source-map',
plugins: [
StyleExtractPlugin,
new ProgressBarPlugin(),
new ExtractTextPlugin('[name].css'),
new HtmlWebpackPlugin({
chunks: ['docs'],
template: 'docs/index.tpl',
filename: 'index.html',
inject: true
}),
new HtmlWebpackPlugin({
chunks: ['examples'],
template: 'docs/index.tpl',
filename: 'examples.html',
inject: true
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
options: {
@@ -145,6 +165,11 @@ module.exports = {
if (process.env.NODE_ENV === 'production') {
delete module.exports.devtool;
module.exports.output = {
path: path.join(__dirname, '../docs/dist'),
publicPath: './',
filename: '[name].[hash:8].js'
};
module.exports.plugins = module.exports.plugins.concat([
new webpack.DefinePlugin({
'process.env': {
@@ -153,7 +178,8 @@ if (process.env.NODE_ENV === 'production') {
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
warnings: false,
drop_console: true
},
output: {
comments: false