Skip to content

Commit

Permalink
Migrate to Webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
amsik committed Feb 5, 2018
1 parent e21c41a commit 358a523
Show file tree
Hide file tree
Showing 12 changed files with 8,747 additions and 4,511 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["stage-3"]
}
72 changes: 72 additions & 0 deletions build/dev.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use strict'

const path = require('path')
const pkg = require('../package.json')
const webpack = require('webpack')

const CopyWebpackPlugin = require('copy-webpack-plugin')

module.exports = {
context: path.resolve(__dirname, '../'),

entry: {
app: './src/main.js'
},

output: {
path: path.resolve(__dirname, ".."),
filename: pkg.module
},

resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': path.resolve('src'),
}
},

module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [path.resolve('src')]
}
]
},

devtool: 'eval-source-map',

devServer: {
contentBase: path.resolve(__dirname, "..", "demo"),
compress: true,
port: 9000,
publicPath: '/',
open: true,
hot: true,
watchOptions: {
poll: false
},
lazy: false
},

plugins: [
new webpack.DefinePlugin({
'process.env': '"development"'
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../dist'),
to: 'dist',
ignore: ['.*']
}])
]
}
56 changes: 56 additions & 0 deletions build/prod.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict'

const path = require('path')
const pkg = require('../package.json')
const webpack = require('webpack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

module.exports = {
context: path.resolve(__dirname, '../'),

entry: {
app: './src/main.js'
},

output: {
path: path.resolve(__dirname, ".."),
filename: pkg.module
},

resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': path.resolve('src'),
}
},

module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [path.resolve('src')]
}
]
},

plugins: [
new webpack.DefinePlugin({
'process.env': '"production"'
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: false ,
parallel: true
})
]
}
File renamed without changes.
5 changes: 3 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
<div id="app"></div>
<div id="app2"></div>

<script src="vue.js"></script>
<script src="../dist/vue-tree.umd.js"></script>
<script src="dist/vue.js"></script>
<script src="../dist/vue-tree.esm.js"></script>
<!-- <script src="dist/vue-tree.esm.js"></script> -->

<script type="x-template" id="demo">
<div class="app">
Expand Down
112 changes: 0 additions & 112 deletions demo/index2.html

This file was deleted.

Loading

0 comments on commit 358a523

Please sign in to comment.