Skip to content

Commit 3103d5a

Browse files
committed
✨ Add browser full build
1 parent 2c8d116 commit 3103d5a

File tree

3 files changed

+124
-1
lines changed

3 files changed

+124
-1
lines changed

build/webpack.release.full.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
var vue = require('vue-loader')
2+
var path = require('path')
3+
var webpack = require("webpack")
4+
var ExtractTextPlugin = require("extract-text-webpack-plugin")
5+
var projectRoot = path.resolve(__dirname, '../')
6+
var cssLoader = ExtractTextPlugin.extract('style-loader', 'css-loader')
7+
const npmCfg = require('../package.json');
8+
9+
var banner = [
10+
npmCfg.name + ' v' + npmCfg.version,
11+
'(c) ' + (new Date().getFullYear()) + ' ' + npmCfg.author,
12+
npmCfg.homepage
13+
].join('\n')
14+
15+
module.exports = {
16+
entry: {
17+
'vue-chartjs': './src/index.js'
18+
},
19+
output: {
20+
filename: './dist/[name].full.js',
21+
library: 'VueChartJs',
22+
libraryTarget: 'umd',
23+
umdNamedDefine: true
24+
},
25+
module: {
26+
preLoaders: [
27+
{
28+
test: /\.vue$/,
29+
loader: 'eslint',
30+
include: projectRoot,
31+
exclude: /node_modules/
32+
},
33+
{
34+
test: /\.js$/,
35+
loader: 'eslint',
36+
include: projectRoot,
37+
exclude: /node_modules/
38+
}
39+
],
40+
loaders: [
41+
{
42+
test: /\.vue$/,
43+
loader: 'vue'
44+
},
45+
{
46+
test: /\.js$/,
47+
exclude: /node_modules/,
48+
loader: 'babel'
49+
},
50+
{
51+
test: /\.css$/,
52+
loader: cssLoader
53+
},
54+
{
55+
test: /\.s[a|c]ss$/,
56+
loader: ExtractTextPlugin.extract('style-loader','css-loader!sass-loader')
57+
},
58+
{
59+
test: /\.json$/, loader: 'json'
60+
}
61+
]
62+
},
63+
eslint: {
64+
formatter: require('eslint-friendly-formatter')
65+
},
66+
babel: {
67+
presets: ['es2015'],
68+
plugins: ['transform-runtime']
69+
},
70+
plugins: [
71+
new webpack.BannerPlugin(banner)
72+
]
73+
}
74+
75+
if (process.env.NODE_ENV === 'production') {
76+
77+
delete module.exports.devtool
78+
module.exports.plugins = [
79+
new webpack.DefinePlugin({
80+
'process.env': {
81+
NODE_ENV: '"production"'
82+
}
83+
}),
84+
new webpack.optimize.UglifyJsPlugin({
85+
compress: {
86+
warnings: false
87+
}
88+
}),
89+
new webpack.optimize.OccurenceOrderPlugin()
90+
// new ExtractTextPlugin('build.css')
91+
]
92+
}

build/webpack.release.full.min.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var config = require('./webpack.release.full.js')
2+
var webpack = require('webpack')
3+
4+
config.output.filename = config.output.filename.replace(/\.js$/, '.min.js')
5+
6+
delete config.devtool
7+
8+
config.plugins = [
9+
new webpack.optimize.UglifyJsPlugin({
10+
sourceMap: false,
11+
compress: {
12+
warnings: false
13+
}
14+
}),
15+
new webpack.optimize.OccurenceOrderPlugin()
16+
]
17+
18+
module.exports = config

build/webpack.release.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ var webpack = require("webpack")
44
var ExtractTextPlugin = require("extract-text-webpack-plugin")
55
var projectRoot = path.resolve(__dirname, '../')
66
var cssLoader = ExtractTextPlugin.extract('style-loader', 'css-loader')
7+
const npmCfg = require('../package.json');
8+
9+
var banner = [
10+
npmCfg.name + ' v' + npmCfg.version,
11+
'(c) ' + (new Date().getFullYear()) + ' ' + npmCfg.author,
12+
npmCfg.homepage
13+
].join('\n')
714

815
module.exports = {
916
entry: {
@@ -51,6 +58,9 @@ module.exports = {
5158
{
5259
test: /\.s[a|c]ss$/,
5360
loader: ExtractTextPlugin.extract('style-loader','css-loader!sass-loader')
61+
},
62+
{
63+
test: /\.json$/, loader: 'json'
5464
}
5565
]
5666
},
@@ -60,7 +70,10 @@ module.exports = {
6070
babel: {
6171
presets: ['es2015'],
6272
plugins: ['transform-runtime']
63-
}
73+
},
74+
plugins: [
75+
new webpack.BannerPlugin(banner)
76+
]
6477
}
6578

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

0 commit comments

Comments
 (0)