Last active
February 18, 2017 16:43
-
-
Save winwu/5049ef99eea808d6661d8b5fe98e6006 to your computer and use it in GitHub Desktop.
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
var path = require('path'); | |
var webpack = require('webpack'); | |
module.exports = { | |
// if you need browsery sync, you should set it to be true. | |
watch: true, | |
entry: { | |
vendor: [ | |
'./resources/assets/js/vendors/jquery.min.js', | |
'./resources/assets/js/vendors/bootstrap.min.js', | |
'./resources/assets/js/vendors/highcharts.js' | |
], | |
main: './resources/assets/js/main.js' | |
}, | |
output: { | |
path: path.join(__dirname, './public/js'), | |
filename: 'build.js', | |
// publicPath: '/public/' | |
}, | |
plugins: [ | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: "vendor", | |
filename: "vendor.bundle.js" | |
}), | |
new webpack.ProvidePlugin({ | |
$: path.join(__dirname, './resources/assets/js/vendors/jquery.min.js'), | |
jQuery: path.join(__dirname, './resources/assets/js/vendors/jquery.min.js'), | |
"windows.jQuery": path.join(__dirname, './resources/assets/js/vendors/jquery.min.js'), | |
'Highcharts': path.join(__dirname, './resources/assets/js/vendors/highcharts.js'), | |
}), | |
], | |
module: { | |
loaders: [ | |
{ | |
test: /\.vue$/, | |
loader: 'vue' | |
}, | |
// 轉 ES6 | |
{ | |
test: /\.js$/, | |
loader: 'babel', | |
// TODO | |
include: [ | |
path.join(__dirname, './resources/assets/js/') | |
], | |
exclude: [ | |
'/node_modules/', | |
path.join(__dirname, './resources/assets/js/vendors') | |
] | |
}, | |
{ | |
test: /\.json$/, | |
loader: 'json' | |
}, | |
// { | |
// test: /\.css$/, | |
// loader:'style!css!autoprefixer' | |
// }, | |
//.css 文件想要編譯,sass就需要這些東西!來編譯處理 | |
// install css-loader style-loader sass-loader node-sass --save-dev | |
// { | |
// test: /\.scss$/, | |
// loader: 'style!css!sass?sourceMap' | |
// } | |
] | |
}, | |
babel: { | |
presets: ['es2015', "stage-2"], | |
plugins: ['transform-runtime'] | |
}, | |
vue: { | |
loaders: { | |
js: 'babel', | |
scss: 'style!css!sass' | |
} | |
}, | |
resolve: { | |
extensions: ['', '.js', '.vue', '.json'], | |
}, | |
// 開啟source-map,webpack 有多種 source-map,在官網文檔可以查到 | |
devtool: 'eval-source-map' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
新版本 處理 bootstrap material 暴露到 global.
npm 需要加裝:
exports-loader
,expose-loader
。在主 Vue component 的 mounted 呼叫:
參考:
*【webpack】expose-loader 插件使用 http://blog.csdn.net/lizixiang1993/article/details/52193724