Created
February 3, 2017 18:23
-
-
Save gldraphael/b7c84eaf5d77e2a2e538c53572e68607 to your computer and use it in GitHub Desktop.
Webpack Config for Vue with ts using av-ts
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 = { | |
entry: './src/app.ts', | |
output: { | |
path: path.resolve(__dirname, './dist'), | |
publicPath: '/dist/', | |
filename: 'app.js' | |
}, | |
// resolve TypeScript and Vue file | |
resolve: { | |
extensions: ['', '.ts', '.vue', '.js'] | |
}, | |
module: { | |
loaders: [ | |
{ test: /\.vue$/, loader: 'vue' }, | |
{ test: /\.ts$/, loader: 'vue-ts' }, | |
{ test: /\.less$/, loader: "vue-style-loader!css-loader!less-loader" }, | |
{ test: /(jpg|png)$/, loader: "file-loader?name=[name].[ext]?[hash]" }, | |
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" }, | |
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" }, | |
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" }, | |
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" }, | |
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" } | |
], | |
}, | |
vue: { | |
// instruct vue-loader to load TypeScript | |
loaders: { | |
js: 'vue-ts-loader', | |
less: 'css!less', | |
ts: 'vue-ts-loader' | |
}, | |
// make TS' generated code cooperate with vue-loader | |
esModule: true | |
}, | |
plugins: [ | |
new webpack.ProvidePlugin({ | |
$: "jquery", | |
jQuery: "jquery" | |
}) | |
], | |
devServer: { | |
port: 8080, | |
host: 'localhost', | |
historyApiFallback: true, | |
watchOptions: { aggregateTimeout: 300, poll: 1000 } | |
}, | |
devtool: '#eval-source-map' | |
} | |
if (process.env.NODE_ENV === 'production') { | |
module.exports.devtool = '#source-map' | |
// http://vue-loader.vuejs.org/en/workflow/production.html | |
module.exports.plugins = (module.exports.plugins || []).concat([ | |
new webpack.DefinePlugin({ | |
'process.env': { | |
NODE_ENV: '"production"' | |
} | |
}), | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
warnings: false | |
} | |
}), | |
new webpack.optimize.OccurenceOrderPlugin() | |
]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment