// webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './src/main.js',
output: {
path: path.join(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [{
test: /\.css$/,
use: [
'style-loader',
'vue-style-loader',
'css-loader'
],
}, {
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('node_modules/vue-octicon')],
exclude: /node_modules/
},
{
test: /\.(png|jpg|jpeg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
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({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
It should resolve the path directory.
It's throwing resolve is not defined error. This issue is coming when I am using vue-cli with webpack. And only when I run npm run build.
path: path.join(__dirname, './dist'),
^
ReferenceError: resolve is not defined
at Object.<anonymous> (/home/praveen/Baseblock/client_webpack/client_webpack/webpack.config.js:7:16)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at requireConfig (/home/praveen/Baseblock/client_webpack/client_webpack/node_modules/webpack/bin/convert-argv.js:97:18)
at /home/praveen/Baseblock/client_webpack/client_webpack/node_modules/webpack/bin/convert-argv.js:104:17
Looks on your stacktrace, problem in your configuration file (/home/praveen/Baseblock/client_webpack/client_webpack/webpack.config.js:7:16).
I was having this issue too, and how I solved it was by putting all of my __dirname paths declared inside the alias, like so :
Alias: {
scss: path.resolve(__dirname, 'src/scss/)
endpath: path.resolve(__dirname, 'src/dist/newjs/')
}
You can then reference the path name in the file later like this: 'scss/default.scss' and then the problem should be resolved. You can also export to the other react JS files using those alias names for shorter directory.
I was having this issue too, and how I solved it was by putting all of my __dirname paths declared inside the alias, like so :
Alias: {
scss: path.resolve(__dirname, 'src/scss/)
endpath: path.resolve(__dirname, 'src/dist/newjs/')
}You can then reference the path name in the file later like this: 'scss/default.scss' and then the problem should be resolved. You can also export to the other react JS files using those alias names for shorter directory.
thanks a lot锛孖 solve the problem by this way
Most helpful comment
I was having this issue too, and how I solved it was by putting all of my __dirname paths declared inside the alias, like so :
Alias: {
scss: path.resolve(__dirname, 'src/scss/)
endpath: path.resolve(__dirname, 'src/dist/newjs/')
}
You can then reference the path name in the file later like this: 'scss/default.scss' and then the problem should be resolved. You can also export to the other react JS files using those alias names for shorter directory.