12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- var Path = require('path');
- var LiveReloadPlugin = require('webpack-livereload-plugin')
- var HardSourcePlugin = require('hard-source-webpack-plugin')
- var ExtractTextPlugin = require('extract-text-webpack-plugin')
- var CopyPlugin = require('copy-webpack-plugin')
- var prod = process.env.NODE_ENV === 'production'
- module.exports = {
- entry: Path.resolve('src/index.js'),
- output: {
- path: Path.resolve('static/src'),
- filename: 'main.js'
- },
- resolve: {
- extensions: ['.js', '.vue', '.json'],
- alias: {
- 'vue$': 'vue/dist/vue.esm.js',
- '@': Path.resolve('src'),
- '@@': Path.resolve('src/components')
- }
- },
- plugins: [
- new LiveReloadPlugin({
- appendScriptTag: true
- }),
- new HardSourcePlugin({
- cacheDirectory: 'node_modules/.cache/hard-source/[confighash]',
- recordsPath: 'node_modules/.cache/hard-source/[confighash]/records.json',
- configHash: function(webpackConfig) {
- return require('node-object-hash')({sort: false}).hash(webpackConfig)
- },
- environmentHash: {
- root: process.cwd(),
- directories: [],
- files: ['package-lock.json', 'yarn.lock'],
- }
- }),
- new ExtractTextPlugin('main.css')
- ],
- module: {
- rules: [
- {
- test: /\.vue$/,
- loader: 'vue-loader',
- options: {
- extractCSS: prod
- }
- },
- {
- test: /\.js$/,
- exclude: /node_modules/,
- loader: 'babel-loader',
- include: Path.resolve('src')
- },
- {
- test: /\.css$/,
- loader: ['style-loader', 'css-loader']
- },
- {
- test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
- loader: 'url-loader',
- options: {
- limit: 10000,
- name: Path.posix.join('static', 'img/[name].[hash:7].[ext]')
- }
- }
- ]
- }
- }
|