Last active
July 18, 2018 21:46
-
-
Save adi518/abd1e54e83aaac863456ed5cccc6ced6 to your computer and use it in GitHub Desktop.
Webpack 4 + Babel 7 (Next) bundle configuration boilerplate for Vue components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"main": "dist", | |
"scripts": { | |
"build": "node_modules/.bin/webpack --config webpack.config.js", | |
"dev": "node_modules/.bin/webpack --config webpack.config.js --watch" | |
}, | |
"peerDependencies": { | |
"vue": "^2.5.2" | |
}, | |
"devDependencies": { | |
"@babel/core": "^7.0.0-beta.51", | |
"@babel/helper-module-imports": "^7.0.0-beta.54", | |
"@babel/plugin-syntax-jsx": "^7.0.0-beta.54", | |
"@babel/preset-env": "^7.0.0-beta.54", | |
"babel-helper-vue-jsx-merge-props": "^2.0.3", | |
"babel-loader": "^8.0.0-beta.4", | |
"babel-plugin-syntax-jsx": "^6.18.0", | |
"babel-plugin-transform-vue-jsx": "^4.0.1", | |
"css-loader": "^1.0.0", | |
"node-sass": "^4.9.2", | |
"sass-loader": "^7.0.3", | |
"url-loader": "^1.0.1", | |
"vue-loader": "^15.2.4", | |
"vue-style-loader": "^4.1.0", | |
"vue-template-compiler": "^2.5.16", | |
"webpack": "^4.12.0", | |
"webpack-bundle-analyzer": "^2.13.1", | |
"webpack-cli": "^3.0.8" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/noamkfir/webpack/tree/webpack-4/template | |
/* Webpack 4 + Babel 7 (Next) configuration boilerplate for bundling Vue components */ | |
const path = require('path') | |
const VueLoaderPlugin = require('vue-loader/lib/plugin') | |
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin // eslint-disable-line | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
filename: 'index.js', | |
path: path.join(__dirname, 'dist'), | |
libraryTarget: 'umd' | |
}, | |
resolve: { | |
extensions: ['.js', '.vue'], | |
alias: { | |
'@': path.join(__dirname, 'src') | |
} | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.vue$/, | |
loader: 'vue-loader' | |
}, | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
options: { | |
presets: [ | |
['@babel/preset-env', { | |
forceAllTransforms: true, | |
}] | |
], | |
plugins: [ | |
'babel-plugin-transform-vue-jsx' | |
] | |
} | |
}, | |
{ | |
test: /\.scss$/, | |
use: [ | |
{ | |
loader: 'vue-style-loader', | |
}, | |
{ | |
loader: 'css-loader' | |
}, | |
{ | |
loader: 'sass-loader', | |
options: { | |
includePaths: [ | |
'./src/sass', | |
'./node_modules' | |
] | |
} | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new VueLoaderPlugin() | |
], | |
mode: 'production' | |
} | |
if (process.env.ANALYZE) { | |
module.exports.plugins.push(new BundleAnalyzerPlugin()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment