0
好的,所以我使用webpack-simple来处理VueJS。我安装了一个名为AdminLTE的主题。我试图通过下面的代码导入它里面的引导文件。当我运行npm run build
时,应用程序在src文件夹内搜索,但AdminLTE位于node_modules文件夹内。如何导入Node_Modules中的特定文件
我应该只导入那些我需要的文件,或者我应该导入整个文件夹。如何正确导入这些文件?
我main.js文件
import Vue from 'vue'
import App from './App.vue'
// import BootstrapCSS from 'admin-lte/bootstrap/bootstrap.min.css'
// import BootstrapCSSTheme from 'admin-lte/bootstrap/bootstrap-theme.min.css'
import 'admin-lte/bootstrap/bootstrap.min.css'
import 'admin-lte/bootstrap/bootstrap-theme.min.css'
new Vue({
el: '#app',
render: h => h(App)
})
我的WebPack配置
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: './dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader','css-loader']
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devServer: {
historyApiFallback: true,
noInfo: 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
})
])
}