diff --git a/build/common-paths.js b/build/common-paths.js deleted file mode 100644 index 1f9b1fe..0000000 --- a/build/common-paths.js +++ /dev/null @@ -1,5 +0,0 @@ -const path = require('path'); - -module.exports = { - outputPath: path.resolve(__dirname, '../', 'dist'), -}; diff --git a/build/config.js b/build/config.js new file mode 100644 index 0000000..a2b8706 --- /dev/null +++ b/build/config.js @@ -0,0 +1,40 @@ +var path = require('path'); + +const config = { + dev: { + env: "dev", + port: 8080, + autoOpenBrowser: true, + assetsRoot: path.resolve(__dirname, '../dist'), + assetsSubDirectory: 'static', + assetsPublicPath: '/', + proxyTable: {}, + // CSS Sourcemaps off by default because relative paths are "buggy" + // with this option, according to the CSS-Loader README + // (https://github.com/webpack/css-loader#sourcemaps) + // In our experience, they generally work as expected, + // just be aware of this issue when enabling this option. + cssSourceMap: false + }, + prod: { + env: "prod", + index: path.resolve(__dirname, '../dist/index.html'), + assetsRoot: path.resolve(__dirname, '../dist'), + assetsSubDirectory: 'static', + assetsPublicPath: '/', + productionSourceMap: true, + // Gzip off by default as many popular static hosts such as + // Surge or Netlify already gzip all static assets for you. + // Before setting to `true`, make sure to: + // npm install --save-dev compression-webpack-plugin + productionGzip: false, + productionGzipExtensions: ['js', 'css'], + // Run the build command with an extra argument to + // View the bundle analyzer report after build finishes: + // `npm run build --report` + // Set to `true` or `false` to always turn it on or off + bundleAnalyzerReport: process.env.npm_config_report + }, +}; + +module.exports = config; diff --git a/build/webpack.base.js b/build/webpack.base.js index 5394b32..102ea9b 100644 --- a/build/webpack.base.js +++ b/build/webpack.base.js @@ -1,11 +1,14 @@ const path = require('path'); -const commonPaths = require('./common-paths'); +const config = require('./config'); -const config = { +isProd = process.env.NODE_ENV === 'prod'; +isDev = process.env.NODE_ENV === 'dev'; + +module.exports = { entry: './src/main.js', output: { filename: 'build.js', - path: commonPaths.outputPath, + path: isProd ? config.prod.assetsRoot : config.dev.assetsRoot, publicPath: '/dist/', }, module: { @@ -43,6 +46,4 @@ const config = { 'vue$': 'vue/dist/vue.esm.js' } }, -}; - -module.exports = config; \ No newline at end of file +}; \ No newline at end of file diff --git a/build/webpack.dev.js b/build/webpack.dev.js index c55372b..68421bd 100644 --- a/build/webpack.dev.js +++ b/build/webpack.dev.js @@ -1,4 +1,4 @@ -const config = { +module.exports = { devtool: '#cheap-module-eval-source-map', devServer: { historyApiFallback: true, @@ -6,14 +6,5 @@ const config = { }, performance: { hints: false - }, - plugins: [ - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: '"development"' - } - }), - ] -}; - -module.exports = config; \ No newline at end of file + } +}; \ No newline at end of file diff --git a/build/webpack.prod.js b/build/webpack.prod.js index 2780a7f..04f75c2 100644 --- a/build/webpack.prod.js +++ b/build/webpack.prod.js @@ -1,11 +1,6 @@ -const config = { +module.exports = { devtool: '#source-map', plugins: [ - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: '"production"' - } - }), new webpack.optimize.UglifyJsPlugin({ sourceMap: true, compress: { @@ -16,6 +11,4 @@ const config = { minimize: true }) ] -}; - -module.exports = config; \ No newline at end of file +}; \ No newline at end of file diff --git a/src/main.js b/src/main.js index f9949ec..11f1352 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,8 @@ -// import Vue from 'vue' -// import App from './App.vue' +import Vue from 'vue'; +import App from './App.vue'; -// new Vue({ -// el: '#app', -// render: h => h(App) -// }) +new Vue({ + el: '#app', + render: h => h(App) +}); console.log('Hello World!'); \ No newline at end of file